A custom virtual machine for the Stars 4X game
a day ago
- Stars! is a 1995 4X game for Windows 3.1 that is difficult to run on modern systems.
- Stars!VM embeds a custom 80286 emulator and Win16-to-Win32 bridge, making the game run as native Win32 with modern features like a file chooser and 4k scaling.
- Signed releases include the compressed original game in a single EXE, ready to play out-of-the-box.
- The emulator runs as a 32-bit binary that works everywhere except 16-bit Windows, and it improves behavior like not dumping config files in system directories and removing copy protection.
- The emulator uses host x87 hardware for floating point and is validated with a differential fuzzer.
- The Win16-to-Win32 bridge maps handles, marshals structs, services DOS interrupts, and enables monitoring via Model Context Protocol (MCP) for AI agents.
- Optimization of turn generation achieved ~2x speedup by reverse engineering hot routines and re-writing them as new 80286 instructions using Fable.
- I/O buffering and native implementation of WaveMix.dll improve performance and eliminate external dependencies.
- The game assets are compressed with a custom LZ algorithm, and a fixed serial code is injected to avoid copy protection issues.
- The project is open source and built with w64devkit, allowing further modification.