Nation0 Effect Anatomy · fn_6424a / fn_644e8 / fn_645bd @ 0x6424a

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.

Timeline: ~02:15 to ~02:30 in Demo Geometry: 75 Deformed Rings × 15 Vertices (1,125 3D Points) Chaos Generator: 3-Call 32-bit LCG PRNG (fn_64b19) VGA Pipeline: 320×160 Centered Video Region @ A1900 Filter: 4-Tap Spatial Feedback Blur (blurBuffer)
About this illustration

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

COMPOSITE · CHAOTIC VORTEX + PHOSPHOR BLUR
Screen Pos (X, Y) 160, 80
Raw Pixel Index Index: 0x00
Depth Shade / Fog Depth Z: ~350
Phosphor RGB (0, 0, 0)
PHASE 045°
Active Inspection: Full composite mode. The chaotic 3D wire ribbons tumble toward the camera, their lines softly diffusing in the 4-tap feedback buffer to create a glowing green phosphor trail.

Rendering Pipeline Stages

Click a stage to inspect its specific math and memory registers.

01

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.

fn_6424a @ 0x642cc & fn_64b19 @ 0x64b19 · 75 records × 0x7a bytes
02

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]
03

VGA Screen Buffer Blit

160 scanlines are copied via 32-bit dword writes to VGA memory segment A1900, centered on the 320×200 display.

copyRowsToEs @ 0x6428c · Target ES:[0xa1900]
04

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 code
05

Depth-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.

fn_645bd & fn_64644 @ 0x645bd · 75 rings × 15 segments

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:

1. 32-Bit Multiply-Add-Rotate PRNG fn_64b19 @ 0x64b19
State_{n+1} = ROL_3( ( State_n × 0x41FBF0E7 + 0x00904E19 ) mod 2³² ) Temporary = (State_n × 0x41FBF0E7 + 0x00904E19) mod 2³² Result = Temporary >>> 15 // returned BEFORE rotating stored state
State at DS:[0x63c15]. Uses 32-bit multiplier and 3-bit left rotate to achieve pseudo-random distribution with low CPU cycles.
2. Three Random Invocations Per Ring 0x642cc..0x64300
θ_{row} = PRNG() & 0xFFF // Random Angle: 0..4095 (0..2π) ΔY = ⌊ ((PRNG() & 0x1FF) × 11) / 16 ⌋ - 176 // Offset Y: -176..+175 ΔX = ⌊ ((PRNG() & 0x1FF) × 11) / 16 ⌋ - 176 // Offset X: -176..+175
Every ring receives an independent random rotational orientation and an eccentric translation in 3D space.
3. Template Vertex Rotation fn_64471 @ 0x64471
X_{rot} = ⌊ ( (X_{template} + ΔX) · cos(θ_{row}) - (Y_{template} + ΔY) · sin(θ_{row}) ) / 512 ⌋ Y_{rot} = ⌊ ( (X_{template} + ΔX) · sin(θ_{row}) + (Y_{template} + ΔY) · cos(θ_{row}) ) / 512 ⌋
Rotates each of the 15 template points (X_k, Y_k) around the center by the ring's unique angle θ_row.

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:

1. Self-Patched 3D Camera Rotation 0x6454c
A = (coordinate₀ · sine + coordinate₁ · cosine) >> 9 B = (coordinate₀ · cosine − coordinate₁ · sine) >> 9
The CPU writes current sin and cos values directly into four IMUL instruction immediates at runtime.
2. Perspective Projection & Depth Flight 0x64572
X_{screen} = trunc( ( X_{cam} · 250 ) / Z_{depth} ) + 160 Y_{screen} = trunc( ( Y_{cam} · 250 ) / Z_{depth} ) + 100 Z_{depth} = Z_{depth} - 8 // When Z < 1, wrap to 700 (Endless tunnel flight)
Perspective scaling via signed IDIV with focal distance 250. Near vertices wrap back to Z=700.
3. Depth-Cued Fog & Color Ramp fn_645bd @ 0x645c3
ColorIndex = max( 0, 21 - ⌊ Z_{depth} / 32 ⌋ )
Near rings receive glowing green (21); distant rings fade smoothly into deep emerald (7) and pitch black (0).

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):

loc_6425C: mov dl, byte ptr [esi + 1] ; DL = right neighbor pixel mov al, byte ptr [esi - 1] ; AL = left neighbor pixel add al, dl ; AL = left + right add al, byte ptr [esi - 140h] ; AL = left + right + top (stride = 320 = 140h) mov bl, byte ptr [esi] ; BL = center pixel 1 add al, bl ; AL = sum of 4 taps for pixel 1 mov ah, bl ; AH = left neighbor for pixel 2 (center 1) add ah, byte ptr [esi + 2] ; AH = left + right neighbor for pixel 2 add ah, byte ptr [esi - 13Fh] ; AH = left + right + top neighbor for pixel 2 add ah, dl ; AH = sum of 4 taps for pixel 2 and eax, 0FFFFFCFCh ; Clear lower 2 bits of AL and AH shr eax, 2 ; Parallel divide by 4! (both AL and AH / 4) mov word ptr [esi], ax ; Write 2 blurred pixels simultaneously to buffer! add esi, 2 dec ecx jnz loc_6425C
1. Parallel 16-bit Bitmask

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.

2. Vertical Scanline Stride

The memory offset -0x140 corresponds exactly to 320 bytes (one row above in Mode 13h linear framebuffer memory).

3. In-Place Feedback and Truncation

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.

GREEN PHOSPHOR DAC PALETTE RAMP (INDICES 0 TO 22):
Index 0 (Black Background) Index 7..21 (Emerald to Glowing Green) Index 22 (White Highlight)

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

1. Phosphor Blur 4-Tap Box Feedback
on Frame Buffer
blurBuffer @ 0x6425c
2. VGA Transfer Copy 320×160 Region
to Segment A1900
copyRowsToEs @ 0x6428c
3. 3D Transform Self-Modifying Rotate
& Perspective Project
fn_644e8 @ 0x644e8
4. Depth Fog Assign Color = 21 - Z/32
& Draw Clipped Lines
fn_645bd & fn_64644
5. Timer & Loop Advance Depth Z -= 8
& Consume PIT Events
finishFn6424aFrame