One line of text drawn four times at four depths. Each copy writes its own bit of the pixel value, and the palette turns every combination of bits into an additive colour blend. Below is a live reconstruction, followed by how each part of the code works.
This uses the scene's real layer constants, colour schemes and palette code (360×480 mode, shift = 145), and the message from the commented-out line 620. The original font is replaced by Anton, and the timer is assumed to tick 60 times a second. The animated objects and the shine sprite are left out. "Planes drawn" simulates the early exit the engine takes on slow machines.
Letters are stored as outlines. A running XOR down each column fills them, and clears the scratch buffer at the same time.
Each of the four copies XORs its own bit into the pixel, so overlaps combine with no z-sorting and no read-modify-write.
Each bit is a coloured light. The palette is built so that index i is the clamped sum of the lights for the bits set in i.
The parallax is the same text drawn four times, each copy scaled toward a vanishing point at the centre of the screen.
SCREEN_Y, which is row 50 (90*50).0, 90*240 and 90*480. setVisiblePage, presumably called from the timer or retrace interrupt, points the CRTC start address at whichever page is ready.A glyph is a list of 16-bit words: the low byte is y and the high byte is x (in plane byte columns). Each word marks a spot where the glyph's outline crosses a column vertically, where a solid run starts or ends.
DrawEdge only XORs the layer's value into those edge pixels of a scratch buffer. It has a fast path with no clipping (@n1) and a clipped path (@n0). In the clipped path, cmp dh,90 / jae rejects both x < 0 and x ≥ 90 with one unsigned compare.
xorfill_xmode then walks down each column keeping an accumulator. It toggles on at a top edge and off at a bottom edge, writes the result to video memory, and zeroes the scratch buffer as it goes:
; for each 4-byte strip, for each of 128 rows xor eax, ds:[si] ; toggle on the edges in this row mov es:[di], eax ; write 4 filled bytes to VGA mov ds:[si], ebx ; ebx = 0: clear the scratch buffer for next frame
DrawEdge wrote, faded once the fill has read and cleared them. Right: what reaches the screen. Where both shapes overlap, the accumulator holds 6 and the pixel turns yellow. Since each layer owns its own bit, the two fills never disturb each other.The scratch buffer is stored strip by strip so the fill can read it sequentially, 32 bits at a time:
offset = y*4 + (x shr 2)*512 + (x and 3) { line 133 }
In Mode X, pixel x lives in plane x mod 4. The scene renders each plane separately into buf[0..3]. A glyph placed at screen x contributes only its columns gx where (x + gx) mod 4 = p to plane p.
So the font stores four pre-decimated variants of every glyph, each with a 6-byte header (offset, length, width). That is why the lookup is (ascii-65)*24 + w*6. get_xx_w picks the variant w = (p − x) and 3 and the starting byte column xx.
x. Only the highlighted columns land in the selected plane. Those columns make up glyph variant w, and their first one lands in plane byte xx. This gives smooth one-pixel scrolling even though each plane is addressed in 4-pixel steps.Planes are written with a growing map mask, so each pass overwrites the planes above it:
order[0]:=15; // 1111 plane 0's image goes to all 4 planes order[1]:=14; // 1110 order[2]:=12; // 1100 order[3]:=8; // 1000
When the display is waiting for a new frame (if find(ready)=-1 then break, line 973), the loop stops early. The frame still looks complete, just at a quarter or half of the horizontal resolution. A slow machine loses detail instead of frames. Drag "Planes drawn" in the demo above to see it.
| Layer | prlx | width (spacing) | width / 42 | depth ≈ 1/prlx |
|---|
Each frame computes:
text_x := 280 - (q shl 1); { 2 px per timer tick } x := round(text_x*prlx + txt[l].shift); x := text_chars_x[ch, layer] + o; { o = byte column from get_xx_w }
text_chars_x is precomputed and loaded from textw480.bin. The commented-out precalc_text (lines 223–253) shows how: cumulative letter positions using each layer's width, with narrow and wide factors for I, L, M, W and others. The spacing ratio matches prlx, so character i of layer k lands at about:
screen_x ≈ shift + prlx_k × (text_x + 4·42·i)
That is a perspective projection with the vanishing point at x = shift, about the centre of the screen. Speed and letter spacing both shrink with distance, so the copies drift apart and line up again as they scroll.
1/prlx − 1. Rays from the eye through one letter hit the screen at four different places. A point at x = shift never moves, so it is the vanishing point.Two simplifications:
y (DrawEdge(x, 0, …)). Only the horizontal direction is 3D: letters don't shrink and don't move toward a horizon.ch_start. When a layer-3 character is fully off the left edge (x < -50, line 272), ch_start moves forward. Layer 3 is the slowest, so it is always the last to leave and the skip is safe for every layer.The "colour" that text passes to DrawEdge is a set of bits. It comes from color_scheme[segment, layer], where the segment depends on the character's position in the message. With the message on line 620, the segment boundaries fall exactly on word boundaries, so every word gets its own colour arrangement:
| Chars | Word | L0 front | L1 | L2 | L3 back |
|---|
Within a segment no two layers share a bit. After the fill, each pixel's value is the set of layers covering it, so the drawing order doesn't matter. Bits 5–7 (32, 64, 128) are reserved for the animated objects and the shine sprite (32 shl l, line 416). The scheme variable on line 256 is never used.
mix_col mode 0 is a per-channel add, clamped at 63 (the VGA DAC is 6-bit). Modes 1 and 2, alpha and 70/30 blends, are never called. set_palette_segment(src, dst, arr, c) sets eight entries: palette[dst+n] := arr[src+n] + c. Each step copies everything built so far and adds one new light:
As a result, palette[i] is the sum of the lights for the bits set in i, clamped at 63. Overlapping layers blend additively, like coloured gels in front of lamps. Try any combination:
Each colour from ANOTHER, SCROLLER and ENJOY, matched to the closest of the 256 colours a VGA card loads by default in mode 13h. In each pair, the left half is the scene's colour and the right half is the nearest default entry. Δ is the straight-line RGB distance in 6-bit DAC units, where 0 is an exact match.
Every single-layer colour has a close match. Three overlap colours don't: olive yellow (40,40,0), dusty pink (40,30,30) and sage (30,40,30). The default palette has no mid-bright yellow and no low-saturation colours at that brightness, so they fall to a darker olive or plain grey.
The default palette here is generated from its standard layout: 16 EGA colours, 16 greys, nine 24-hue rings at three brightness and saturation levels, and 8 blacks. Hex values convert 6-bit values with v × 255 / 63.
Bits are only clash-free within one segment. The layers are spread out horizontally, so layer 1 can be showing a letter of SCROLLER (value 3 = bits 0+1) while layer 3 shows a letter of ANOTHER in the same spot (value 9 = bits 0+3). Both use bit 0, so where they overlap that bit cancels under XOR:
The overlap shows a slightly different colour. It is easy to miss in motion and was probably accepted on purpose.