TeREp2
Manual, human-made reverse engineering of the Terep2 demo.
- Type: PC port
- Game: Terep 2: Deformers
- Runs on Windows
- By harrison3000
- Latest release v0.1-alpha4, 2026-05-10
- Source: https://github.com/harrison3000/terep2-re
README
TeREp2-re - Reverse engineering the terep2 demo
Disassembly/Recompilation of the Terep2 demo to run on modern systems
The original ASM has been cleaned up and converted to a C file, each instruction implemented as a macro, the innermost loops of the rendering functions have been rewritten in normal C to speed things up a bit, on a modern Ryzen this uses less than 2% of one core (even when rendering at higher resolutions), so performance optimizations are not really necessary for modern systems, but who knows? somebody might want to run this in retro systems, on a ESP32, a DS or things like that...
The primary target is Win32 (both 32 and 64 bit), surprisingly it runs even on win98 (tested on qemu). It also runs on Linux on a SDL window but this is mostly for testing and debugging, if you are on linux you are better off running the win32 version on wine
Some bugs in the renderer have been fixed, the physics was barely touched and should feel identical to the original, the x87 square root has been replaced by a integer algorithm, it gives the same result as floats using floor instead of rounding, theres a verifyer to run and verify replays recorded in a very old version with more pristine code.
This project has 2 main targets (or rather, will have when I get the github automation thing working again):
terep2re32.exeandterep2re64.exe: Code converted to run natively on Windows, from 98 all the way to 11, include improvements such as pausing physics, higher resolutions, config file, debug mode... you probably want thisterep2sx.exe: As close to the original as possible, but modified to not require the x87 FPU (integer square root), not do the XMS memory test thing (this makes it compatible with FreeDOS out of the box), fix the camera not turning when running on fast current computers and compacted to be as small as possible (simple zero run compactation, no fancy algorithms)...
For building instructions see BUILDING.md
AI/LLM usage disclaimer and rules
Limited AI usage, for things like generating boilerplate or doing small corrections to the GUI is acceptable, but touching the ASM code or other critical parts using AI is a big no-no, we dont do that here
AI has been used as a research tool and answering question about old Win32 APIs and odd x86 behaviors
The parallel terep2vb project has been consulted for things like discovering specific addresses and to discover what each function is meant to do, but I took care to not look directly at the code, only the comments, for the high resolution development I only asked the AI to give a brief overview of the rasterization process and implemented the code myself, I even did some things not done in the terep2vb like supporting different aspect ratios!
Project history
This project started in 2019 (remember back then? everything was so different somehow), I didn't actually unpack the Guardian Angel obfuscation, I just dumped the memory using the Dosbox debugger after the game was already running instead, I managed to make a unpacked exe that ran and discovered the structure of some of the code using ghidra but quickly lost interest, fast forward 6 years later and I discovered there's a whole community of Terep fans and this motivated me to start again
Progress
Some of the project history in screenshots
Very early build running on win16 protected mode, no palette, no sound, no physics, nothing... just a very crude proof of concept, by the way this early version crashed if I tried to render more than one frame
After a bunch of fixes, playable, but no sound yet
One of the first Win32 builds
Current build, look at all those pixels and sharp edges! (higher resolutions are also available)