proomt

Search

Search posts, papers, and topics

All posts

Chris Wellons5 min readintermediate

A custom virtual machine for the Stars! 4X game

Summary

Stars!VM is a 32‑bit Windows executable that embeds a custom 80286 emulator and a Win16‑to‑Win32 bridge to run the 1995 4X game Stars! without any external emulators. The author adds differential fuzzing, hot‑routine patching, I/O buffering and asset compression, achieving about a 2× speedup in turn generation.

  • The emulator runs x87 floating‑point directly on host hardware and is validated with a differential fuzzer that compares emulated vs. JIT‑executed instructions.
  • Hot game routines (e.g., the L’Ecuyer PRNG) are identified via tracing and replaced with custom 80286 instructions, cutting turn generation time roughly in half.
  • A Win16‑to‑Win32 bridge maps 16‑bit handles, marshals structs, services DOS interrupts, and implements WaveMix.dll natively, allowing the game to run as a native 32‑bit process.
  • Buffered I/O and a custom LZ‑based compression reduce asset size from ~3 MB to ~1.5 MB and lower I/O overhead during turn generation.

Engineers building emulators, legacy‑API bridges, or performance‑critical VM layers can learn practical techniques for validation, hot‑code patching, and integration with modern OS services.

7/10

Related reading

  1. Some things Veloren does differently

    Veloren’s engine uses a custom ECS, a novel ‘chonks’ voxel storage, full‑world pre‑generation, physically‑based erosion, and a scalable real‑time simulation (rtsim) that keeps tens of thousands of NPCs active, achieving ~50% CPU usage on a 48‑core server with 500+ players.

    Lobstersjsbarretto.com8 minHN5lobste.rs70
  2. M4N VM family, now GA: Highest per-core IOPS and throughput for I/O and memory-bound workloads

    Google Cloud’s GA‑available M4N VM family pairs 5th‑gen Intel Xeon CPUs with Google’s custom Titanium offload to deliver up to 1 M IOPS, 25 GiB/s block‑storage throughput, 400 Gbps VM‑to‑VM bandwidth, and a 26 GB/vCPU memory ratio (up to 5.9 TiB RAM). The design targets memory‑bound, I/O‑intensive workloads (Oracle, SAP HANA, vector search, real‑time analytics) and claims >20 % TCO reduction for…

    Google Cloud Bloggoogle.com5 min