Analysis model: gpt-5.5 xhigh

Chaos 3D by Dodger - Technical Dissection

Chaos 3D is an August 1992 MS-DOS demo by Dodger. Pouet lists it as a MS-DOS demo released in August 1992, Demozoo gives the date as 17 August 1992, and the Hornet 1992 index carries chaos3d.zip as Chaos 3D by Dodger.

Release year: 1992

This is not a multipart story demo. It is a 386-oriented interactive 3D object viewer wrapped in a short intro sequence: text and picture setup, optional MiniMod music, an unchained VGA 320x240 backend, a shape-file parser, fixed point object transforms, face sorting, filled polygons, reflection/stars, and small aligned ball/text blitters. The shipped documentation describes it as unfinished, and that matches the binary: the solid-polygon path is real, the shape format has line records, but the provided data has Lines: 0 and the hot path is built around faces.

The public article deliberately omits the old personal contact block found in the archive text files. The technical notes below use the executable, data files, and public catalog metadata only.

Chaos 3D renderer dataflow

The image above is a generated static-analysis map. It is not a raw emulator screenshot.

Front-page media note: the card uses the generated renderer dataflow map as a static preview. I did not make a GIF for this pass because no local Chaos 3D runtime frames exist yet, and the available evidence here is static disassembly plus the parsed shape/rendering pipeline rather than a captured timed playback sequence.

Sources

Archive

The examined archive is the Hornet mirror copy of chaos3d.zip:

chaos3d.zip   176727 bytes
airy.mod      133120 bytes  1992-08-17 14:57
demosite.com    1129 bytes  1992-10-26 05:23
info.txt          305 bytes  1992-11-21 14:25
readme           2550 bytes  1992-08-18 11:24
rot.exe        219292 bytes  1992-08-17 22:08
runme.bat          28 bytes  1992-08-17 21:37
shapes.dat      22211 bytes  1992-06-11 22:30

Hashes:

7e731685fff7b454f16d8ae77da453a5834d222629b876e0c25fc35ad0d49fa1  chaos3d.zip
0257d0beb023c939f520185c2b35ca18f98da9cc99b1bb6925e70fb6a9cbbbd8  airy.mod
c2ad85db79effafee21bc21264ae6051c2a69e977e5f19b0426ae33fb0326292  demosite.com
6f081c3f9c20062ba25858a3ebe82fe3b558aad1d0c932cfd58ec278afb1c6a2  info.txt
08e6ff6e0ae3dc887581524fa28bd57ba4cb96889a49fb01069a8e55c284885f  readme
ef25859a8648ce579d8441ba115c1bb239f50b59ad96472966a8d2302f4a1112  rot.exe
8b22298f32c6b4772f4e3a8384d5fc8e9bc8099ab4eeb22fab651e54ae333855  runme.bat
a01bf959de7a035143eaa48f4f2297fba7f3ccd6b22bdb19a1813eb0664b9481  shapes.dat

runme.bat launches the real program as:

rot -m airy.mod shapes.dat

The -m switch enables the MiniMod music path. Without it the renderer can be run as a silent shape viewer.

Runtime Timeline

The useful timing here is structural rather than soundtrack-synchronized:

00:00.000  DOS loads ROT.EXE and Borland startup reaches main at 1745h.
00:00.000  Optional -m path initializes MiniMod and loads AIRY.MOD.
00:00.000  Main stores default viewport/window values and enters VGA setup.
00:00.000  Set320x240Mode programs BIOS mode 13h into unchained 320x240.
00:00.000  ReadData parses SHAPES.DAT into per-shape point, face, and state records.
intro      Intro/picture/text helpers prepare background assets and ball masks.
loop       Keyboard/mouse/demo state updates the selected shape.
loop       RenderStars/erase helpers update background/reflection areas.
loop       Render @ 097Ah transforms points, projects vertices, sorts faces,
           and calls polygon span fillers.
loop       ShowPageX flips the CRTC start address, then the page base toggles
           by 4B00h bytes for the next frame.
exit       ESC restores text mode and exits through the Borland runtime.

The article uses static disassembly rather than an exact video capture. The reason is practical: the effect is interactive, the shipped text files include old contact details, and DOSBox-X's own compatibility table records that some emulator configurations misrender the startup panning/scroller effects.

Pipeline-Map-To-Code Concordance

The published visual on this page is a generated renderer dataflow map, not a runtime screenshot. It is still code-backed: each major box in the map corresponds to a recovered executable path, parsed data structure, or VGA helper described below.

Visible artifact:

images/chaos-3d-pipeline-map.png
evidence type: generated static-analysis map
runtime status: no local Chaos 3D frame sequence is published yet
source evidence: ROT.EXE disassembly, SHAPES.DAT parser, symbol/debug tail,
                 and archive metadata

The pipeline represented by the map is:

ROT.EXE Borland C++ MZ
  -> optional -m MiniMod setup for AIRY.MOD
  -> Set320x240Mode unchains VGA mode 13h into 320x240 Mode X
  -> ReadData parses SHAPES.DAT into fixed-point point/face records
  -> intro/picture/text helpers prepare static buffers and masks
  -> Render @ 097Ah computes CosSin, transforms/project points, sorts faces
  -> Polygon converts projected faces into y-indexed edge tables
  -> ScanLineX writes plane-mask-aware horizontal spans
  -> star/reflection/blit helpers layer the non-object effects
  -> ShowPageX flips by CRTC display-start address

The dataflow map deliberately separates high-level C control from VGA assembly helpers:

Evidence boundary: this page should be read as static code/data analysis, not as a playback reconstruction. Runtime capture remains a follow-up task. A future GIF or frame set should come from direct DOSBox/video output of the interactive renderer, with contact material omitted, rather than from animating the generated pipeline map.

Executable Shape

rot.exe is a Borland C++ MZ executable with a debug/symbol tail after the loaded image:

physical file size        219292 bytes
MZ-declared image size    199408 bytes
header size                  512 bytes
loaded image              198896 bytes
relocations                   19 at file offset 003Eh
entry                    0000:0000
stack                    3087:0080
minalloc                 0000h
maxalloc                 FFFFh

The bytes after the declared MZ image are useful because they preserve many source and symbol names:

intro.c demo.c data.c rot.c vekk.c poly.c scaling.c mouse.c spheres.c
DAC.ASM FASTX.ASM SCANX.ASM SCANALLX.ASM SETMODEX.ASM SHOWPAGX.ASM
BITBLTX.ASM MEM2VIDX.ASM BLTMASKX.ASM BLITLETM.ASM PIXELX.ASM FIXED.ASM
_Set320x240Mode _ShowPageX _Render _ReadData _BresPoints _Polygon
_BitBlitX _CopySystemToScreenX _BlitMaskedX _PixelX _FixedMul _FixedDiv _CosSin

The program is C at the control level and assembler at the hardware level. That division is visible everywhere: C-style stack frames, malloc/file I/O around shape parsing, then small assembly helpers for VGA ports, page flips, planar spans, masked blits, and fixed-point math.

Main Setup

main begins at 1745h. It first checks for -m or /m; if present it uses far calls into the embedded MiniMod support before video setup. It then copies default viewport constants into globals, enters the VGA backend, parses the shape file, prepares graphics buffers, runs the intro/setup path, and falls into the interactive loop around 1E88h.

Important calls in order:

1745h  main
177Ah  MiniMod initialization when -m is present
08F0h  Set320x240Mode
19A7h  ReadData
40E3h  graphics/window descriptor setup
02C2h  intro/page reveal helper
3DA3h  LoadBalls / aligned masked image builder
1E88h  interactive loop

The key loop polls input, changes shape index/zoom/rotation/translation, toggles real/fake shading and reflection/stars, renders the current object, optionally draws the reflection pass, flips the page, then XORs the active page base with 4B00h.

Shape File Parser

shapes.dat is plain text. A shape starts with a name line such as -C-, then sections like:

Points: 17
...
AnimPoints: 0
Lines: 0
Faces: 14
4, 1 2 7 8, 4, 32

ReadData at 19A7h parses this into a compact binary layout:

shape record stride     33h bytes
point record stride     0Ch bytes
line record stride      16h bytes
face record stride      0Dh bytes

Each point is promoted immediately into 16.16 fixed point:

; conceptual form of the parser loop
fscanf("%d, %d, %d", &x, &y, &z)
movsx eax, word ptr [x]
shl   eax, 10h
store dword point.x
movsx eax, word ptr [y]
shl   eax, 10h
store dword point.y
movsx eax, word ptr [z]
shl   eax, 10h
store dword point.z

That up-front conversion is important. The renderer never has to wonder whether object coordinates are text integers or fixed-point numbers; by the time Render sees them, object coordinates, translations, and rotation products all live in the same 32-bit 16.16 domain.

Faces are packed as small records:

offset +00  type/flags byte
offset +01  vertex count
offset +02  first vertex index
...
offset +0C  color/shade byte

The parser reads line records too, but the distributed shapes.dat keeps Lines: 0 for the visible shapes. The working display path is polygonal.

VGA Mode X Setup

Set320x240Mode at 08F0h starts from BIOS mode 13h, then turns it into an unchained 320x240 planar mode:

08F0  mov ax,0013h
08F3  int 10h
...
      mov dx,03C4h
      mov ax,0604h
      out dx,ax          ; sequencer memory mode / chain behavior
      mov ax,0100h
      out dx,ax          ; synchronous reset
      mov dx,03C2h
      mov al,0E3h
      out dx,al          ; misc output / dot clock
      mov dx,03C4h
      mov ax,0300h
      out dx,ax          ; restart sequencer

It then unlocks CRTC register 11h, writes a ten-word CRTC table, selects all planes with Sequencer Map Mask 0Fh, and clears A000h with rep stosw.

The page size used by the runtime is 4B00h bytes, which is 320 * 240 / 4. Because Mode X stores four pixels per byte address across four planes, a full 320x240 page occupies 19,200 byte offsets inside VGA memory. The main loop uses two active pages by toggling the global page base with:

xor word ptr [page_base], 4B00h

Other setup/transition paths use the larger sequence of page starts 0000h, 4B00h, 9600h, and E100h.

Page Flip

ShowPageX at 0952h writes the CRTC display-start address:

; parameter: start offset
mov bl,0Dh
mov bh,low(start)
mov cl,0Ch
mov ch,high(start)

wait_display_not_active:
  in  al,03DAh
  test al,01h
  jnz wait_display_not_active

out 03D4h,bx       ; CRTC start low
out 03D4h,cx       ; CRTC start high

wait_vretrace:
  in  al,03DAh
  test al,08h
  jz wait_vretrace

The function waits on 03DAh before and after the CRTC writes. That is the classic VGA reason the output looks stable: all heavy drawing happens to the hidden page, and the visible page changes through display-start registers rather than a full 64 KB copy.

Rectangle And Scanline Inner Loops

The low-level rasterizer treats an (x, y, pageBase) destination as:

offset = 80 * y + (x >> 2) + pageBase
plane  = x & 3

FillRectangleX at 06A0h clips the rectangle, computes masks for the left and right edge pixels, writes the Sequencer Map Mask through 03C4h/03C5h, then fills row bytes. The row body is the important part:

; one row, simplified
out 03C5h,left_mask
mov es:[di],color
inc di

out 03C5h,0Fh
rep stosb              ; whole four-plane byte columns

out 03C5h,right_mask
mov es:[di],color

add di,row_advance

ScanLineX at 0720h is the polygon span version. It clips y, clamps the left/right endpoints, computes the same planar address, ANDs the edge masks with a caller-supplied mask, and writes the middle with rep stosw when possible. This means the polygon filler can ask for a horizontal span without knowing the VGA plane edge cases.

The plane masks come from tiny tables indexed by x & 3. A span beginning at pixel x=5, for example, starts in plane 1 of byte x>>2; the helper writes only the affected planes for the left byte, all planes for middle bytes, and only the affected planes for the right byte.

Fixed-Point Math

The engine assumes a 386. The renderer uses operand-size prefixes in real mode to get 32-bit registers and signed 32-bit multiplies.

FixedMul at 43D4h:

push bp
mov  bp,sp
mov  eax,[bp+04h]
imul dword ptr [bp+08h]
shr  eax,10h
pop  bp
ret

That helper leaves EDX holding the high half from IMUL; many callers immediately run shl eax,10h / shrd eax,edx,10h after the call, folding the high product bits back into the 16.16 result. In other words, the multiply contract is really EDX:EAX product state, not a tidy C-style int32_t return.

FixedDiv at 43E6h widens the numerator around a 16-bit fractional shift, uses signed division, then leaves a 16.16-style result split for callers that push/use DX:AX:

push bp
mov  bp,sp
mov  eax,[bp+04h]
cdq
shrd eax,edx,10h
sar  edx,10h
idiv dword ptr [bp+08h]
shld edx,eax,10h
pop  bp
ret

CosSin at 5218h fills caller-provided dword slots. The render entry calls it three times, once for each object angle, and stores the sine/cosine pairs in globals around 1076h..108Ah.

Render Entry At 097Ah

Render receives a shape pointer in [bp+4]. Its first task is to prepare the trigonometry:

097D  mov  di,[bp+04h]       ; shape
0985  push 107Ah
0988  push 1076h
098B  push word ptr [di+04h] ; first angle
098E  call 5218h             ; CosSin
0994  push 108Ah
0997  push 1086h
099A  push word ptr [di+06h] ; second angle
099D  call 5218h
09A3  push 1082h
09A6  push 107Eh
09A9  push word ptr [di+08h] ; third angle
09AC  call 5218h

It then updates global dirty bounds (2E80h..2E8Eh), clears or redraws the background depending on the reflection/star flag, and handles animation points if the shape has them.

The main point transform loop starts around 0E8Eh. For each source point:

  1. load object-space x/y/z dwords from the parsed point array;
  2. add shape translation dwords from offsets 0Ah, 0Eh, and 12h;
  3. apply the three-axis rotation through repeated FixedMul calls;
  4. add final object translation to the rotated coordinates;
  5. compute a perspective denominator from viewer distance minus transformed z;
  6. divide and scale to screen coordinates centered at (160, 120);
  7. write a 6-byte projected vertex record at 18EEh.

The screen-space store is compact:

10D1  sar  edx,10h
10D5  add  dx,00A0h
10E5  mov  [18EEh + index*6],ax       ; screen x
...
1143  sar  edx,10h
1147  add  dx,0078h
1158  mov  [18F0h + index*6],ax       ; screen y
116A  mov  [18F2h + index*6],ax       ; projected/depth z

This is why the later polygon code uses a 6-byte stride. It no longer sees fixed-point object points; it sees screen x, screen y, and a depth-ish z word.

Face Visibility And Sorting

After point projection, Render walks every face record. The important loop begins at 118Eh. It initializes a face index list at 10F6h and a visibility flag array at 12F4h, then extracts the first three vertex indices from each face record.

For faces with more than two vertices it computes two edge vectors in screen space and takes a cross product:

v01 = (p0 - p1) / 2
v12 = (p1 - p2) / 2
cross = v01.x * v12.y - v12.x * v01.y

The disassembly shows the two multiplications and subtract at 12D1h..130Ah. If the sign says the face is back-facing and the face is not marked as a special two-sided face, the face is skipped.

For visible faces, the renderer averages the projected z values of every vertex:

135F  vertex_index = face.vertex[i]
1375  movsx eax,word ptr [18F2h + vertex_index*6]
1382  add  [14F2h + face_index*4],eax
...
13B9  idiv vertex_count
13C3  mov  [14F2h + face_index*4],eax

The index list is then sorted:

1548  push 1675h      ; comparator
154B  push 0002h      ; element size
154D  push face_count
1553  push 10F6h      ; index array
1556  call qsort

Comparator 1675h subtracts the averaged z value of one face index from the other. The draw loop then visits the sorted list and calls either Polygon for filled faces or a simpler helper for small/special records. The result is a painter-style filled polygon engine: no z-buffer, but ordered faces.

Polygon Edge Tables

Polygon at 2A59h receives:

face record pointer
projected vertex array pointer, normally 18EEh
shade parameter

It first finds min-y, max-y, min-x, and max-x among the face's vertices. Then it walks the polygon boundary in both directions from the top vertex to the bottom vertex. The two boundaries are rasterized into two y-indexed tables:

3070h  one edge x table
2E90h  the other edge x table

The edge walker is BresPoints at 2986h. It is a classic Bresenham routine specialized for polygon filling: instead of plotting pixels, it stores one x coordinate for each scanline y.

Conceptually:

if abs(dx) > abs(dy):
    x-major walk, update y when error crosses threshold
else:
    y-major walk, write x_table[y] and step y every iteration

The code clips against the current vertical bounds before storing:

; inside BresPoints
cmp y, [06F0h]        ; top clip
jl  skip_store
cmp y, [06ECh]        ; bottom clip
jg  skip_store
mov [table + y*2], x

The second half of Polygon, around 3020h..30F3h, alternates boundary segments:

302E  push 3070h      ; left/right table A
3056  call 2986h      ; BresPoints(edge)
...
308E  push 2E90h      ; left/right table B
30B7  call 2986h      ; BresPoints(edge)

This is the hidden heart of the filled-vector part. Expensive arbitrary polygons become a pair of integer x tables, and the final fill stage is just one horizontal span per scanline.

Polygon Fill Variants

The fill tail at 2D15h..2F2Eh chooses between several shading paths using the low bits of the face type and the global real/fake shading toggle at 06F2h.

Common path:

push mask
push color_or_shade
push pageBase
push y
push [2E90h + y*2]
push [3070h + y*2]
call 0720h            ; ScanLineX

The simplest variant uses the face color byte directly:

2EF4  load mask
2F02  load face color
2F08  push pageBase
2F0C  push y
2F0F  push edgeB[y]
2F13  push edgeA[y]
2F17  call ScanLineX

The fake/animated shade variant adds a moving shade offset derived from the global phase byte at 1067h and a small table at 0662h:

2E4D  mov  al,[1067h]
2E55  and  bx,003Fh
2E5F  add  ax,[0662h + bx*2]
2E73  call ScanLineX

The mask byte is normally FFh, but faces with bit 10h set use AAh. Because ScanLineX ANDs this with edge plane masks, the face can cheaply produce a dotted/striped planar fill without changing the scanline algorithm.

Pixel, Blit, And Mask Helpers

PixelX at 4397h is the single-pixel version of the same Mode X address calculation:

offset = 80 * y + (x >> 2) + pageBase
mask   = table[x & 3]
out 03C5h,mask
mov es:[offset],color

CopySystemToScreenX and the masked blitters are more interesting because they use VGA latches and plane masks instead of a linear framebuffer. The masked blit family around 41A2h/4262h sets Graphics Controller bit mask index 08h, computes the same destination byte offset, then repeatedly:

lodsb                  ; source/generated mask byte
out 03C5h,al           ; select affected planes
mov al,es:[bx]         ; load VGA latch
mov es:[di],al         ; rewrite through plane/mask logic

That pattern looks strange if read as normal memory code. It makes sense only as VGA latch programming: the read primes internal VGA latches and the write combines source/mask state with the selected planes.

LoadBalls at 3DA3h builds prealigned versions of several ball sizes. It loops alignment values 0..7, copies rows from embedded art tables, and calls the system-to-screen/masked-image builder for sizes 8, 12, 16, 20, 24, and 30. That preprocessing keeps the runtime blitter from doing per-pixel alignment work while drawing reflected/stamped objects.

Stars And Reflection

The reflection/star toggle is stored at 06F4h. When disabled, the viewport bottom is the full 240 lines. When enabled, the code reduces the active object area to roughly 200 lines and reserves the lower part for reflection handling.

The render path calls:

3551h  star/background update helper
097Ah  Render current shape
3657h  reflection strip copy when enabled
0952h  ShowPageX

The reflection helper copies strips with the same Mode X blit backend, walking from the object bottom toward the bottom of the 240-line page. It is not a second 3D render. It is a screen-space mirror/copy effect layered after the real polygon pass.

Audio

airy.mod is a normal 4-channel ProTracker module:

title       MOD.Airy
signature   M.K.
orders      17
patterns    13

Notable sample names include voice.aah, Fifths.snd, BellDoom, Bass Guitar, AAAUGH, Drum.Tight, Snare.Hiss, Hat.Sss, Tom.U20, Guitar Long, GameOver, and Cowbell.

The executable contains MiniMod v0.03 strings and far-call setup code. Music initialization happens before the VGA mode switch when -m is present. The renderer itself does not appear to be scripted to module positions; it is an interactive loop with optional background music.

What The Code Is Doing

The whole program is a compact early-1990s PC 3D workbench:

  1. parse text object data into fixed-point points and small face records;
  2. set unchained VGA so four planar pages can be addressed by CRTC start offsets and page-base math;
  3. transform all points with 386 16.16 fixed-point multiply/divide helpers;
  4. project to a 6-byte screen-space vertex list;
  5. reject faces by screen-space winding and sort visible faces by averaged z;
  6. convert each polygon to two y-indexed edge tables with Bresenham;
  7. draw each scanline through a plane-mask-aware Mode X span routine;
  8. layer stars, reflection, aligned ball/text sprites, and page flips around the polygon pass.

That explains the demo's feel. It is neither a pure effect reel nor a simple wireframe object spinner. It is a C/ASM fixed-point solid polygon engine with an intentionally exposed data format, running close enough to VGA hardware that the inner loops are mostly about turning mathematical spans into correct plane masks and CRTC flips.