Inside the Chaotic Green Wire Vortex & Phosphor Blur.
How Nation0 generates an organic, tumbling 3D wire vortex from a 15-point base template perturbed by a 3-call LCG PRNG across 75 rings, rendered with self-modifying perspective projection and a parallel 4-tap phosphor decay filter.
The interactive preview illustrates line rasterization and feedback using generated rings. Its closed rings, connecting struts, clipping, and blur boundaries are simplified; the original draws adjacent point pairs and uses signed word arithmetic. Depth color is a per-record shade, not a Z-buffer.
Interactive Pipeline Inspector
Rendering Pipeline Stages
Click a stage to inspect its specific math and memory registers.
Chaotic Ring Generation (LCG PRNG)
At initialization, 75 rings are built from a 15-vertex template (0x60f40), applying 3 PRNG calls per ring: random rotation angle θ, random Δ Y, and random Δ X.
Frame Diffusion & Phosphor Blur Filter
Every frame begins with a dual-pixel 4-tap box filter over the working buffer to create luminous CRT phosphor decay trails.
blurBuffer in fn_6424a @ 0x6425c · Buffer DS:[0x60f7c]VGA Screen Buffer Blit
160 scanlines are copied via 32-bit dword writes to VGA memory segment A1900, centered on the 320×200 display.
Self-Modifying 3D Rotation & Projection
Rotates (X, Y) vertices in 3D camera space, applies perspective division (focal length = 250), advances depth Z (Z ← Z - 8), and wraps near vertices (Z < 1 → 700).
fn_644e8 @ 0x644e8 · Patches IMUL operands in live codeDepth-Cued Fog & Bresenham Line Loops
Assigns green phosphor shades based on Z-depth (color = 21 - Z/32) and rasterizes 14 adjacent segments from each 15-point record.
Why the Mesh is Chaotic: The 3-Call LCG PRNG fn_64b19 & fn_64471
Unlike static terrain grids, Nation0 builds a chaotic, twisting ribbon vortex. The engine stores a single 15-vertex polygon template at 0x60f40 and deforms it 75 times using a 32-bit multiply-add-rotate pseudorandom generator:
DS:[0x63c15]. Uses 32-bit multiplier and 3-bit left rotate to achieve pseudo-random distribution with low CPU cycles.Fixed-Point Plane Rotation & Perspective Projection fn_644e8 / 0x644e8
In each frame, the camera rotates around the chaotic vortex. Rather than reading rotation matrices from RAM, the CPU patches instruction immediates directly in code:
IMUL instruction immediates at runtime.IDIV with focal distance 250. Near vertices wrap back to Z=700.The Dual-Pixel x86 Blur Assembly Loop blurBuffer @ 0x6425c
To apply an in-place four-tap filter to 53,120 bytes per pass, the inner loop processes two 8-bit pixels in parallel using the 16-bit register AX (split as AL and AH):
The bitmask AND EAX, 0xFFFFFCFC clears bits 0 and 1 of both AL and AH so that SHR EAX, 2 divides both 8-bit bytes simultaneously without bit bleeding.
The memory offset -0x140 corresponds exactly to 320 bytes (one row above in Mode 13h linear framebuffer memory).
The filter operates in-place on working buffer 0x60f7c. Left, right, above, and center are averaged in scan order. Earlier writes affect later samples. Truncation dissipates low values; a constant low-valued field is preserved, so there is no universal 3/4 decay factor.
Clipping and Bresenham: how endpoints become pixels
fn_64644 (0x64644..0x64b0f) first clips signed 16-bit endpoints against X = 0..318 and the current Y bounds at DS:[0x6373c..0x6373e]. Intersections use signed integer division. The modified endpoints are written back to the caller, which chains the next segment from those words.
major = max(abs(dx), abs(dy)); minor = min(abs(dx), abs(dy)) error = 2 * minor − major if error < 0: advance only on major axis; error += 2 * minor else: advance on both axes; error += 2 * (minor − major)
This is the integer error-accumulator idea behind Bresenham: additions and comparisons decide when the minor coordinate must catch up. Nation0 specializes it with signed word arithmetic, linear pointer steps (±1, ±320, or diagonal combinations), a 0x4000 error bias, and paired writes walking inward from both ends. The second endpoint is pre-stepped; very short segments have a special early exit. The interactive preview uses a conventional single-ended Bresenham implementation, so its endpoint coverage is illustrative rather than byte-identical.
The original mesh path has no per-pixel depth test: fn_645bd chooses a shade for each record, calls the line helper for adjacent pairs, and lets later writes overwrite earlier ones. The blur pass precedes the VGA transfer; new lines enter the working buffer for the next displayed frame. The transfer copies 316 bytes per row, skipping the final four bytes, over 160 rows.
Complete Frame Pipeline Overview
on Frame Buffer blurBuffer @ 0x6425c
to Segment A1900 copyRowsToEs @ 0x6428c
& Perspective Project fn_644e8 @ 0x644e8
& Draw Clipped Lines fn_645bd & fn_64644
& Consume PIT Events finishFn6424aFrame