X-87: a procedural landscape demo in 256 bytes of DOS x86 + x87
X-87 is a 256-byte DOS real mode demo for Outline 2026 that renders a stylized barren landscape using x86 plus x87 (386+) floating point code and VESA 2 (1994) 640x400 32 bpp graphics. It grew out of p5.js sketches the author made in mid 2021 and revisited in early 2024 and 2025, with the landscape found mostly by accident through iterative tweaking of oscillator parameters and transforms, particularly scale. Rendering takes about 13 minutes at default DOSBox cycles (3000, 286 era), ~2m30 at 20000 cycles (late 486 era), and 2m10 at max cycles, running on an i7 7700 CPU.
The port happened in stages: porting the p5.js code to an x87-like stack model led to experimentation with Gforth, since Forth maps well to x87 (though x87 is sometimes more flexible). A crude greyscale DOS port came next at ~320 bytes, followed by optimization of FPU code and constants to make room for colors, then a dither-like colorization where color increments depend on averaged pixel brightness. Further shrinking came from overlapped and truncated floating points, packed color increments and fewer FPU instructions.
Remaining work focused on compatibility and artifacts: black squares caused by tricky segment initialization and VESA paging/banking were fixed by reusing palette data for a float constant and reusing bx state in the px_sat loop. A version compatible with Bochs and FreeDOS (not tested on real hardware) required packing the two main loops into one and using the halves of ECX as a frame counter / oscillator index, while avoiding fcomi to stay at 386-era compatibility. The author is satisfied with the result but suspects 32 bpp may not be justified and could perhaps be done in 256 colors; resolution scaling requires constant changes, and convergence is faster and artifacts less visible at moderate resolutions.
Read the original onirom.frDiscussion
Sources
-
onirom.fr
X-87 - DOS 256 bytes
Terms
- x87 — The x86 floating-point coprocessor instructions, stack-based, available on 386 and later processors.
- real mode — The legacy 16-bit x86 operating mode used by DOS, with no memory protection.
- VESA — A DOS-era graphics API standard (e.g. 640x400 32bpp modes) giving access to higher resolutions and color depths.
- dither — A technique that uses small structured variations in pixel values to simulate colors or smooth gradients.
- POV notes — not used





