Analysis model: gpt-5.5 xhigh
Plasma by Bret Mulvey - Technical Dissection
Subject
Plasma is Bret Mulvey's April 1988 MS-DOS VGA demo. It is one of the useful
pre-1990 PC reference points because the shipped archive contains both the
Turbo Pascal 4.0 source and a ready-made PLASMA.IMG field. The program is not
a realtime per-pixel plasma in the later Amiga/PC-sine-table sense. It first
generates or loads a 320x200 field of palette indices, then animates that fixed
field by rotating VGA palette entries.
Release metadata:
- Release year: 1988
- Release month: April 1988
- Author: Bret Mulvey
- Platform: MS-DOS
- Display: VGA mode
13h, 320x200x256 - Sound: none
- Source language: Turbo Pascal 4.0
- Package examined:
plasma_mulvey.zip - Main executable:
PLASMA.EXE - Source file:
PLASMA.PAS - Stored image file:
PLASMA.IMG
Sources:
- Demozoo production page
- Pouet production page
- Pouet NFO page
- Scene.org file page
- Scene.org archive download
- Defacto2 file page
The documentation and NFO contain old online contact IDs. Those are deliberately omitted here.
Runtime Capture

The contact sheet above is from a local DOSBox-X capture:
Emulator: DOSBox-X 2026.01.02 SDL2
Capture date: 2026-06-20
Machine: svga_s3
CPU core/cycles: normal, 30000 cycles
Sound: disabled
Command: dx-capture /v PLASMA.EXE
Capture stream: MPEG-TS/H.264, 10.986667 seconds
Timing zero: beginning of captured stream
Input script: Escape injected after 8 seconds
Published runtime frames:
| Timestamp | Screen state |
|---|---|
00:00.500 |
Loaded plasma field with the initial green/blue/red palette phase. |
00:01.000 |
Same 64,000-byte field; the red/blue/green bands have advanced by palette rotation. |
00:02.000 |
The central blue/red valley has changed color assignment without any pixel data changing. |
00:04.000 |
Later palette phase with stronger blue/green inversion in the upper field. |
00:06.000 |
Another palette-wheel position before the scripted exit. |
The 00:08.000 frame was excluded because it is already in the post-Escape
text-mode transition.
The important visual point is that every published runtime frame is still the
same 320x200 field. What changes is the DAC state, not the pixel map. That is
why the contact sheet belongs next to the palette code below: PLASMA.EXE
does not redraw the field every frame, it rotates the palette over a fixed
image that was loaded from PLASMA.IMG or generated into the same 64K buffer.
The faster clip below is sliced directly from the DOSBox-X capture video. It is the most compact way to see the point above: the spatial field stays fixed while the RGB bands roll through it via DAC palette rotation.

The raw stored image, rendered once with the source palette before animation, is useful as a separate reference:

Runtime-To-Code Concordance
The runtime GIF and still frames are direct slices of the DOSBox-X run. They show one idea repeatedly: the spatial image is fixed, and only the VGA DAC palette changes.
| Runtime evidence | Code path / data path | What it proves |
|---|---|---|
images/plasma-mulvey-source-image.png |
Raw PLASMA.IMG, exactly 0xFA00 bytes, rendered as one 320x200 mode-13h screen with the palette ramps from PLASMA.PAS. |
The visible cloud field is a stored palette-index framebuffer, not a stream of generated RGB frames. |
Runtime frames 00:00.500 through 00:06.000 |
Normal archive path opens PLASMA.IMG and block-reads 64,000 bytes into A000:0000. |
A normal run does not regenerate the field; it loads the same byte map before entering the animation loop. |
| Palette-cycle GIF | rotatePalette(p, 1, 192, +1) at compiled load offset 062Fh; palette upload helper at load offset 0008h. |
The motion in the GIF is palette rotation over stable framebuffer contents. |
| Identical cloud contours across every published frame | No A000h writes happen in the palette-rotation loop after the initial image load. |
The contour motion is perceptual color reassignment, not per-frame plasma recomputation. |
| Three-color roll through red, blue, and green bands | Source palette builds three 64-entry ramps: green-to-red, red-to-blue, and blue-to-green, with active indices 1..192. |
The color wheel is source-level data design, not an emulator artifact. |
| Smooth branching field in the source render | adjust and subDivide implement midpoint displacement with nonzero guards and clamp values to 1..192. |
The saved image is generated terrain/cloud data; the demo separates expensive creation from cheap playback. |
| DOSBox-X exit at the injected Escape boundary | Outer repeat loop rotates palette until keypress, then reads the key and restores text mode. | The capture ends by scripted input, not by a finite demo timeline. |
This makes the page's media/code relationship unusually clean: source image is the framebuffer, the GIF is the DAC rotation, and the Pascal source explains both without needing guesswork from the binary alone.
Archive Contents
The scene.org archive contains the executable, source, documentation, and the already-generated image:
PLASMA.DOC 440 bytes
PLASMA.EXE 7680 bytes
PLASMA.IMG 64000 bytes
PLASMA.PAS 3538 bytes
Hashes of the examined files:
b63bcc55e39c04f693851b178ce5671d47349bf2c242b1bbb22623b2bde338a8 plasma_mulvey.zip
7d46648045b9b308afd14bae39287fc2d86da5479a3913cdb2a908eb55096041 PLASMA.DOC
d4ed976a01a92561271ae07838c1827c9d9e8eb674ceeaa81a3ef7a01e81acca PLASMA.EXE
3c73f2a930f6c0f5ce981b0bb9b0b65f9f8aa81a1e6e21cdf41cd86f35a0ce00 PLASMA.IMG
d45857ac9cb3f3d78b497a71d6feb33ddb77c3addb1ecd3f0e290f55c21225b2 PLASMA.PAS
PLASMA.IMG is exactly one mode-13h screen:
size: 64000 bytes
dimensions: 320 x 200
minimum: 1
maximum: 192
zero bytes: 0
corners: 28, 45, 56, 83
The absence of zero bytes is expected. Color index 0 is reserved as a grey
background and as an "unfilled pixel" sentinel during generation. The final
stored field is clamped into 1..192.
MZ And Turbo Pascal Shape
PLASMA.EXE is a normal Turbo Pascal MZ executable:
file size 7680 bytes
MZ header size 592 bytes
load image size 7088 bytes
entry point CS:IP = 0000:0704
initial stack SS:SP = 021A:4000
relocation entries 141
minimum extra alloc 045F paragraphs
maximum extra alloc A45F paragraphs
The source says Turbo Pascal 4.0, and the binary shape agrees: a compact Pascal runtime, many relocations, a Pascal stack/data model, far calls into runtime helpers, and source-level routines compiled into the load image.
After subtracting the 0x250 byte MZ header, the relevant source routines map
approximately like this:
| Load offset | Source routine |
|---|---|
0008h |
VGA palette setter via BIOS INT 10h / AX=1012h. |
006Ch |
Direct PutPixel into A000h. |
00BCh |
Direct GetPixel from A000h. |
0111h |
adjust, the midpoint value writer. |
029Bh |
subDivide, the recursive rectangle splitter. |
062Fh |
rotatePalette, the animation loop body. |
070Eh |
Main program body after Turbo Pascal startup. |
0713h |
Inline mode set, mov ax,0013h; int 10h. |
The executable is therefore useful for confirming memory and BIOS behavior, but the shipped Pascal source is the main evidence for the algorithm.
Program Flow
The whole program is short:
set VGA mode 13h
build a 193-color palette:
index 0 = grey
1..64 = red rising, green falling
65..128 = red falling, blue rising
129..192 = green rising, blue falling
upload all 256 palette entries with BIOS INT 10h / AX=1012h
try to open PLASMA.IMG
if file is missing, or if any command-line parameter is present:
randomize the four screen corners
recursively fill the image in A000h
write 64000 bytes to PLASMA.IMG
else:
read 64000 bytes from PLASMA.IMG into A000h
repeat:
rotate palette entries 1..192 by one slot
upload the palette again
until a key is pressed
read the key and restore Turbo Pascal's previous text mode
Two details matter:
- A normal run with the included archive does not regenerate the plasma field.
It simply block-reads
PLASMA.IMGintoA000:0000. - The animation does not touch the framebuffer. It only rotates palette
entries
1..192and uses BIOS to upload the palette.
VGA Mode And Framebuffer Access
The mode set is an inline byte sequence in the Pascal source and appears in the
binary at load offset 0713h:
mov ax,0013h
int 10h
Pixel access is direct conventional Turbo Pascal mem access to segment
A000h. The address formula is:
offset = 320 * y + x
screen[offset] = color
The compiled PutPixel and GetPixel routines therefore contain:
load A000h into ES
multiply y by 0140h
add x
store or load one byte at ES:DI
This is not optimized assembly; it is 1988 Pascal code doing direct VGA writes. The expensive part is not a realtime display kernel, so the compiler overhead does not matter once the field has been generated and saved.
Palette Layout
The palette is a 256-entry array of three-byte records:
record = R, G, B
entry count = 256
byte count = 768
DAC range = 0..63 per component
The generated wheel uses only entries 0..192:
p[0] = (32, 32, 32)
p[1..64] = (i, 63-i, 0)
p[65..128] = (63-i, 0, i)
p[129..192] = (0, i, 63-i)
So the three active ramps are:
- green to red;
- red to blue;
- blue to green.
Entries 193..255 are left black/zeroed by Pascal's initialized data behavior.
They are never used by the generated field because the algorithm clamps every
stored pixel to 1..192.
The palette upload routine fills a DOS Registers structure:
AX = 1012h BIOS set block of DAC registers
BX = 0 first register
CX = 256 count
ES:DX = palette 768-byte RGB table
INT 10h
Later VGA demo code would usually write ports 03C8h/03C9h directly. This
program keeps the code portable and simple by using BIOS every frame.
Stored Image Format
PLASMA.IMG has no header. It is exactly:
row 0: 320 palette indices
row 1: 320 palette indices
...
row 199: 320 palette indices
The block I/O calls use a record size of one byte:
read 0xFA00 bytes into A000:0000
write 0xFA00 bytes from A000:0000
0xFA00 is decimal 64,000. The file is therefore tied directly to mode 13h's
linear framebuffer size.
The Midpoint Adjustment
The core generator is the adjust routine. In prose, it does this:
adjust(point A, target point M, point B):
if M is already nonzero:
return
d = abs(A.x - B.x) + abs(A.y - B.y)
v = (screen[A] + screen[B]) / 2
v += (random_unit - 0.5) * d * roughness
clamp v to 1..192
screen[M] = trunc(v)
roughness is the source constant F = 2.0. The displacement amplitude is
therefore proportional to the Manhattan distance between the two endpoints.
Large rectangles get large random displacement; small rectangles get small
displacement. That is what gives the final field broad clouds with noisy local
detail.
The nonzero guard is important. During recursive subdivision, multiple rectangles can meet at the same edge midpoint. The first writer owns that pixel; later calls leave it alone, preserving continuity between neighboring rectangles.
Recursive Subdivision
The recursive splitter receives a rectangle:
subDivide(x1, y1, x2, y2)
Its stop conditions are:
if key pressed: return
if width < 2 and height < 2: return
Then it finds the rectangle center:
x = (x1 + x2) div 2
y = (y1 + y2) div 2
It adjusts the four edge midpoints:
top: (x1,y1) -> (x,y1) -> (x2,y1)
right: (x2,y1) -> (x2,y) -> (x2,y2)
bottom: (x1,y2) -> (x,y2) -> (x2,y2)
left: (x1,y1) -> (x1,y) -> (x1,y2)
If the center is still unfilled, it writes the average of the four corners:
center = (top-left + top-right + bottom-right + bottom-left) / 4
Then it recurses into four subrectangles:
top-left
top-right
bottom-right
bottom-left
This is a midpoint-displacement plasma-cloud generator. It is related to the diamond-square family, but the implementation is screen-oriented and compact: edge midpoint displacement, center averaging, then four recursive calls.
Generation Cost
For a full 320 x 200 screen, recursive filling touches most pixels once but
does it through Pascal calls, real arithmetic, random numbers, GetPixel,
PutPixel, and a recursion stack. That is why the documentation warns that
the first run takes a few minutes to create the image file.
The archive includes PLASMA.IMG, so the normal demo path avoids this cost:
open image
BlockRead(image, A000:0000, 0xFA00)
enter palette cycle loop
The command PLASMA NEW forces regeneration because any command-line parameter
selects the "create a new image" branch.
Palette Rotation Inner Loop
The animation loop calls rotatePalette(p, 1, 192, +1) repeatedly. The routine
first copies the whole palette into a local 768-byte temporary. Then it walks
the requested index range and copies from the shifted position:
q = p
for i = n1 to n2:
source = n1 + ((i + d) mod (n2 - n1 + 1))
p[i] = q[source]
upload p to VGA
For the only runtime call:
n1 = 1
n2 = 192
d = 1
range length = 192
The effective result is:
p[1] = old p[2]
p[2] = old p[3]
...
p[191] = old p[192]
p[192] = old p[1]
That shifts the color assigned to each stored index, while the 64,000 bytes in VRAM stay unchanged. One full visual color cycle takes 192 loop iterations.
The compiled loop at load 062Fh shows the same structure:
copy 0300h bytes from p to local q
for i in range:
compute modulo source index
multiply palette index by 3
copy 3 bytes from q[source] to p[i]
call the palette-upload helper at load offset 0008h
The per-frame work is therefore roughly:
768 bytes copied to q
192 records copied back to p = 576 bytes
one BIOS DAC-block upload = 768 bytes
keyboard check in the outer repeat loop
No A000h writes occur during animation.
Why It Looks Alive
The stored field is a height/color-index map, not RGB pixels. Neighboring values are correlated by midpoint subdivision, so the map contains smooth regions and branching boundaries. The palette is a closed color wheel. When the wheel rotates, any contour of equal index appears to flow through red, green, and blue.
This is why the effect is cheap after startup:
- the spatial complexity is precomputed into
PLASMA.IMG; - the temporal motion is all in the VGA DAC;
- the display memory never changes during the runtime loop.
That also explains the captured frames. The cloud structure is identical at
00:00.500, 00:02.000, and 00:06.000; only the colors associated with the
same index values have moved.
Recreating It
A faithful recreation only needs the source-level model:
- Enter 320x200x256 mode.
- Create the 193-entry active palette with grey index 0 and three 64-entry RGB ramps.
- If an image exists, read 64,000 bytes directly into the framebuffer.
- Otherwise seed four random corner values in
1..192, recursively subdivide the screen, clamp every value to1..192, then save the 64,000 bytes. - Repeatedly rotate palette entries
1..192by one slot and upload the full 256-entry palette. - Stop on a keypress and restore text mode.
The historically interesting part is not size coding or cycle-counted VGA trickery. It is the combination of a fractal/generated field, a saved raw framebuffer, and hardware palette animation in 1988 PC/VGA code. Later PC demos would make plasma more realtime and more optimized, but this one is already the core idea in a clear, source-backed form.