Analysis model: gpt-5.5 xhigh
Over The Edge by Sorrox - Technical Dissection
Scope
Over The Edge is Sorrox's MS-DOS/GUS demo that placed third in the PC Demo
competition at The Gathering 1995. This writeup is based on the public party
archives, archive/file inspection, asset conversion, MZ layout analysis, and
static 16-bit disassembly of OTE.EXE.
Public references:
- Demozoo production page: https://demozoo.org/productions/7262/
- Demozoo The Gathering 1995 page: https://demozoo.org/parties/41/
- Pouet production page: https://www.pouet.net/prod.php?which=5038
- Pouet The Gathering 1995 page: https://www.pouet.net/party.php?when=1995&which=43
- Scene.org archive used here: https://files.scene.org/get/parties/1995/thegathering95/demo/ote.zip
- Pouet-linked duplicate archive: https://files.scene.org/get/parties/1995/thegathering95/demo/sor_ote.zip
Offset notation:
0x...offsets in code sections below are linear offsets inside the loaded MZ image, after subtracting the 0x1030-byte DOS header from file offsets.- Far-call targets are written as
segment:offset -> linear, because this is a segmented real-mode program rather than a flat protected-mode executable. - The labels for parts are inferred from file names, load order, and rendering loop shape unless a file name or embedded string proves the name directly.
This is not a source-level reconstruction. The binary is compiled enough that many high-level calls are Borland-style runtime/file/memory helpers, so the stable evidence is the direct hardware I/O, table layout, file sizes, and hot loops.
Archive Identity
Two archives were checked:
26b6ba7276bb771dd2860013e297d600182a43bed2ab99160dc26480beb19b42 ote.zip
7a232f6d5b5f23761988ea3b8f7b0288efa5f1cce432f700011ef6926eb0a349 sor_ote.zip
Their payloads are effectively the same; only the small FILE_ID.DIZ differs.
Pouet links sor_ote.zip, while the The Gathering 1995 party directory also
contains ote.zip.
ote.zip contents:
OLKVER.MOD 597,396 bytes
REPLAY.RPL 91,200 bytes
BAK1.SRX 64,896 bytes
NEW3.SRX 64,896 bytes
SORROX.SRX 64,896 bytes
TUNNEL.SRX 64,896 bytes
OFF1.SSS 64,000 bytes
OFF2.SSS 64,000 bytes
SQRT.TAB 64,000 bytes
DEC.RPL 45,000 bytes
ENDPART.PCX 41,397 bytes
FRACT.LYS 32,768 bytes
OTE4.PCX 24,268 bytes
VALPHA.COR 15,760 bytes
POINTS.SAV 11,724 bytes
VRVERTEX.XXX 10,812 bytes
APEFACES.XXX 10,740 bytes
VRFACES.XXX 7,014 bytes
APEVERTE.XXX 5,748 bytes
11.RAW 4,864 bytes
22.RAW 4,864 bytes
33.RAW 4,864 bytes
44.RAW 4,864 bytes
BALL1.RAW 4,864 bytes
FAK1.RAW 4,864 bytes
MUR.RAW 4,864 bytes
SJAKK.RAW 4,864 bytes
TAKPLANK.RAW 4,864 bytes
FACEFACE.XXX 4,308 bytes
FACEVERT.XXX 2,460 bytes
OTE.EXE 73,744 bytes
FILE_ID.DIZ 124 bytes
Important file hashes:
dcb714514f5fa2bc860c380f2610b165f57d2c12895b085236d18fdb6a41d622 OTE.EXE
b0b396d397224f80c4168096a1a25878be0ed1300e61a0224f3a721ec8fe0b12 OLKVER.MOD
4c45d22302a24839fb94dea905428f6250a5c3b32d8df16eacbb9c9b37700f63 BAK1.SRX
0f91253bac43a3a36ed29b6c0665a9ae5fdd3077cc66edb7a6105fd7fea9479d NEW3.SRX
818a0c0f9232dcce0cb73d0081d469cbd1117a311c1d3697f844067aa6cd1729 SORROX.SRX
22237aeb4f6584b9509b2baa3511b18e4d488df2e13d6254df859ce6695efa1d TUNNEL.SRX
2a65089e8e2ee2e47d0224cd5dba00a8aefd450ee834244572390759c2a91f3b OTE4.PCX
74e887f6e51506078da5dd0fc6254c4542d2e961487e2863f159a807b43dbfb3 ENDPART.PCX
061edfa5f95481c76abf93f676e44a1e7698ad3da66357183927041f18e77841 APEFACES.XXX
747ba2835eb58216adfab61ecca8925a5853c6f7adc2887317afe3a919e145b3 APEVERTE.XXX
37aa4dc250081beb4f5361b6f2ba80a740f4279bef9f8b9590de4caad0e01fb4 VRFACES.XXX
25f9a4d38661b6db4539f8b0a21628dc7f1c2233b26648a7ea4c7302f6f262a4 VRVERTEX.XXX
64b476422588f7944dd4c9415d1507ca3500f996cbcf27a73708fb9118a2fcb1 FACEFACE.XXX
548b533284d5f2cc505cf8abc05f70041d5c295a06620df2ad663a6c1f552cc6 FACEVERT.XXX
Asset Roles
The archive is unusually readable because the big resources are separate files instead of being packed into an overlay.
OLKVER.MOD is an 8-channel FastTracker-style module (8CHN). The sample names
identify Sorrox and OVER THE EDGE; the player path is GUS-specific.
REPLAY.RPL and DEC.RPL are replay/data sidecars. REPLAY.RPL is large
enough to be a player/support blob, while DEC.RPL is used near the effect data
rather than being a normal image.
The four .SRX files are Sorrox image files. Their on-disk shape is:
0x0000..0x007f 128-byte header, including "SorroX Grafix Image!"
0x0080..end literal/RLE-compatible image payload
last 768 bytes palette-shaped VGA RGB data in the files inspected
The last 768 bytes in these files are all 0..63 VGA DAC channel values, so they are palette-shaped. The loader path examined below decodes the image payload to VGA memory; palette application appears to be handled by the separate DAC/fade helpers rather than inline in the SRX decode loop. Converted visually by interpreting the 64,000-byte literal bodies and palette-like tails:
BAK1.SRXis a blue background/noise plate.NEW3.SRXis a large Sorrox logo image.SORROX.SRXis a narrower Sorrox/logo strip.TUNNEL.SRXis a small high-contrast pattern source for a tunnel/displacement part.
OTE4.PCX and ENDPART.PCX are 640x480 4-plane PCX images. OTE4.PCX is the
title card. ENDPART.PCX is the end/credits screen; address-style release
details in that image are intentionally not reproduced here.
The .RAW files are all 4,864 bytes. Interpreted as 64x76 unsigned-byte images
they look like small texture/material sources rather than screen-sized pictures.
Their names point at surface uses: wall/floor/board/checker/ball/fake panels.
OFF1.SSS, OFF2.SSS, and SQRT.TAB are exactly 64,000 bytes each. They are
not normal pictures; they are screen-sized byte tables. SQRT.TAB is a radial
or distance table candidate, while the two OFF*.SSS files behave like offset
or phase maps for a 320x200 table effect.
FRACT.LYS is 32,768 bytes, which fits a half-screen or 128x256 table. It is
data for a fractal/noise/displacement pass rather than an image format with a
header.
The .XXX files are object meshes, but they are not all the same disk format:
FACEVERT.XXX 2,460 bytes = 410 * 6-byte word vertex records
APEVERTE.XXX 5,748 bytes = 958 * 6-byte word vertex records
VRVERTEX.XXX 10,812 bytes = 901 * 12-byte fixed-point vertex records
FACEFACE.XXX 4,308 bytes = word-index/attribute stream
APEFACES.XXX 10,740 bytes = word-index/attribute stream
VRFACES.XXX 7,014 bytes = word-index/attribute stream
That matches the two transform paths in the code. Some source vertices are
three signed words (x,y,z, six bytes). The larger VR object uses three 32-bit
fixed-point coordinates (x,y,z, 12 bytes). Transformed vertices are commonly
expanded to 12-byte records in memory, even when the source file used compact
word vertices.
The disk face files are best treated as word streams plus attributes; forcing a single record width onto all of them gives bad answers. In memory, however, the main draw loop clearly expects a 14-byte face record:
+0 word vertex index 0
+2 word vertex index 1
+4 word vertex index 2
+6 word vertex index 3
+8 word color/material byte in low byte
+10 word draw bucket/pass selector
+12 word extra flag or unused word
The disassembly reads four vertex indices, a color byte, and the pass selector
at +0x0a. So the stable statement is: the loader/preprocess side builds or
uses a 14-byte in-memory face table, while the original face files are compact
word streams.
Executable Shape
OTE.EXE is a normal DOS MZ executable, not a DOS/4GW or PMODE/W protected-mode
program.
file size: 73,744 bytes
MZ image size: 73,744 bytes
header size: 4,144 bytes (0x1030)
loaded image: 69,600 bytes
relocations: 1,029 entries
entry point: CS:IP 0000:000b
entry file off: 0x103b
stack: SS:SP 1800:4e20
The large relocation table and far calls make it look like a Borland/Turbo
Pascal-family segmented program with inline assembly. That matters: many
interesting calls are not flat call near edges. For example, the first visible
part of the entry chain is:
0000b: lcall 0ee9:0000 ; runtime init
00010: lcall 0e87:000d
00015: lcall 0e23:005d
0001a: lcall 0e17:00ae
0001f: lcall 0df1:0250
00024: lcall 0d77:017d
00029: lcall 09b3:02c6
0002e: lcall 0948:0000
Later main-sequence calls reach the visible demo parts:
000cb: lcall 0522:14e0 ; linear 0x06700
000d3: lcall 0e2a:042d
000d8: lcall 0e2a:0273
000dd: lcall 0e2a:0273
000e2: lcall 0e2a:0273
000f8: lcall 0e2a:006d
0012c: lcall 0e2a:004b
00145: lcall 0e87:0308
0014e: lcall 094a:00d0 ; linear 0x09570
00153: lcall 0e2a:0013
00158: lcall 01e4:0cf9 ; linear 0x02b39
0015d: lcall 001a:0e8a ; linear 0x0102a
00162: lcall 0e2a:0013
00167: lcall 06ed:070b ; linear 0x075db
0016c: lcall 037e:0e6b ; linear 0x0464b
00171: lcall 04b8:05b7 ; linear 0x05137
00176: lcall 0e2a:0013
The code uses 386 operand-size instructions (EAX, IMUL r/m32, IDIV, REP STOSD/MOVSD) while staying in real mode. That is a common 1994-1995 trick: keep
the DOS/runtime environment simple, but use 32-bit arithmetic for fixed-point
geometry and fast clears/copies.
Embedded strings confirm the expected startup flow:
SorroX demo-system v1.00 (final beta)
ULTRASND
Using UltraSound at base address ...
8088 8086 80286 80386 80486 Pentium Future
bytes of free conventional memory
Kb of EMS memory available
Kb of XMS memory available
Enabling graphics mode
Loading music
Loading data
VGA and Timing
The demo has several direct VGA helpers. The most important one is the retrace
wait at 0x91c7:
091c7: mov dx,03dah
091ca: in al,dx
091cb: test al,08h
091cd: jne 091ca ; wait until not in vertical retrace
091cf: in al,dx
091d0: test al,08h
091d2: je 091cf ; wait for start of vertical retrace
091d4: retf
This gives the classic two-phase wait: first leave the current retrace window, then catch the next one.
The 64 KB clear and present helpers use 32-bit string ops:
091d5: xor eax,eax
091db: mov cx,3e80h
091de: mov es,[bp+6]
091e1: xor di,di
091e4: rep stosd ; clear 64,000 bytes
091eb: push [0854] ; destination segment, normally A000h
091f2: pop es
091f4: mov ds,[bp+6]
091fb: mov cx,3e80h
091ff: rep movsd ; copy 64,000 bytes to VGA memory
0xe6cd is a far-call version of the same clear:
0e6d7: mov ax,[bp+6]
0e6da: mov es,ax
0e6dc: xor eax,eax
0e6df: xor di,di
0e6e1: mov cx,3e80h
0e6e4: rep stosd
Palette I/O is similarly direct. 0xd856 writes one DAC entry:
0d861: mov dx,03c8h ; DAC write index
0d864: mov al,[bp+0c]
0d867: out dx,al
0d868: inc dx ; 03c9h data port
0d869: mov al,[bp+0a] ; red
0d86c: out dx,al
0d86d: mov al,[bp+08] ; green
0d870: out dx,al
0d871: mov al,[bp+06] ; blue
0d874: out dx,al
0xe604 streams a 768-byte palette:
0e66c: mov dx,03c8h
0e682: mov di,[bp-486]
0e686: mov al,[bp+di-400]
0e68a: mov dx,03c9h
0e68d: out dx,al
0e694: jne 0e67e ; 0x300 channel bytes
There are two graphics setups. One is a BIOS mode-13h/tweaked-mode entry:
0e70f: mov ax,0012h
0e712: int 10h
0e714: mov ax,0013h
0e717: int 10h
0e719: mov bx,0140h
0e71c: shr bx,3
0e71f: mov cx,0140h
0e722: shr cx,2
0e726: mov dx,03d4h
...
0e737: mov dx,03c4h
0e73a: mov al,04h
0e73c: out dx,al
0e73e: in al,dx
0e73f: and al,0f6h
0e741: out dx,al
0e742: mov dx,03d4h
0e745: mov al,14h
0e749: in al,dx
0e74a: and al,0bfh
0e74c: out dx,al
0e74d: mov dx,03d4h
0e750: mov al,17h
0e752: mov ah,0e3h
0e754: out dx,ax
This is the usual unchaining path: mode 13h first, then Sequencer/CRTC tweaks for planar addressing.
The object part has another setup at 0x3c4a, writing Misc Output and CRTC
registers directly:
03c54: mov al,0e3h
03c56: mov dx,03c2h
03c59: out dx,al
03c5a: mov ax,2c11h
03c5d: mov dx,03d4h
03c60: out dx,ax
03c61: mov ax,0d06h
03c64: mov dx,03d4h
03c67: out dx,ax
03c68: mov ax,3e07h
...
03c8b: mov ax,0616h
03c8e: mov dx,03d4h
03c91: out dx,ax
That part later uses Sequencer Map Mask writes during spans, so it is truly using planar VGA behavior instead of just drawing to a chunky back buffer.
SRX Loader
The .SRX loader begins at 0x4c00. It builds a Pascal-style filename on the
stack, opens the file through the runtime, allocates a scratch block, then reads
the 128-byte header:
04c16: lea di,[bp-50h]
04c19: lds si,[bp+4] ; source Pascal string
04c1c: lodsb
04c1d: cmp al,4fh
04c21: mov al,4fh ; clamp filename length
04c23: stosb
04c27: rep movsb
...
04c61: push -0fh
04c63: lcall 0ee9:028a ; allocate/read buffer
04c75: les di,[2606]
04c7b: push 0080h
04c82: lcall 0ee9:0ab6 ; read 128-byte header
The helper at 0x4b80 is the interesting part. It is an RLE-to-planar copier:
04b80: mov bp,[2618] ; current plane mask
04b85: mov es,[25fa] ; destination segment
04b89: mov di,[261a] ; destination offset
04b8d: mov ah,[25fc] ; line width/limit from header
04b91: mov dx,[2616] ; x counter
04b99: xor cx,cx
04b9b: mov cl,[2612] ; pending run count
04b9f: lds si,[2606] ; compressed chunk
04ba4: add bx,si ; chunk end
...
04bae: stosb ; write pixel byte into selected plane
04baf: inc dl
04bb1: cmp dl,ah
04bb3: je 04bb9 ; next scanline/plane boundary
...
04bb9: shl bp,1
04bbb: cmp bp,8
04bbe: jle 04bc5
04bc0: mov bp,1 ; wrap plane mask 1,2,4,8,1
04bc5: sub di,dx ; same byte column, next plane
04bc9: mov ax,bp
04bcb: mov dx,03c5h
04bce: out dx,al ; VGA Sequencer Map Mask data
...
04bd9: lodsb
04bda: cmp al,0c0h
04bdc: jb 04be9 ; literal
04bde: xor al,0c0h ; low six bits = repeat count
04be0: mov cl,al
04be6: lodsb ; repeated byte
04be7: jmp 04bae
Three inspected SRX bodies (BAK1, NEW3, and SORROX) contain no bytes >=
0xc0 in the first 64,000 image bytes, so this RLE loop degenerates to a
literal plane upload for them. TUNNEL.SRX does contain 0xc0-class bytes, so
the same loader can exercise its run path there. The important point for the
visuals is that SRX decode is not the hot effect loop; it is an asset upload
path that selects VGA planes and advances the plane mask at scanline boundaries.
Trig Tables
The table builder at 0x80a0 creates two 720-entry word tables at 0x4ee8 and
0x5488. It uses runtime math calls, then stores signed 16-bit sine/cosine
style values:
080a0: push bp
...
080d0: ; angle loop, bp-2 = 0..02cfh
08125: call runtime real math
0813d: mov [di+4ee8h],ax
...
081a6: call runtime real math
081be: mov [di+5488h],ax
081c8: cmp word [bp-2],02cfh
081cf: jne 080d0
The 720-count is notable. It is not a 256-entry texture-angle table and not a 1024-entry power-of-two table. Angles are doubled before indexing:
07375: mov bx,[bp+1a]
07378: mov si,[bp+18]
0737b: mov di,[bp+16]
0737e: add bx,bx
07380: add si,si
07382: add di,di
07384: mov ax,[bx+4ee8h]
073a2: mov ax,[bx+5488h]
That strongly suggests degree-like animation counters with half-degree or direct 0..719 wrapping, compiled for clarity rather than table-mask speed.
Compact 3D Transform and Projection
The transform routine exists at least twice; 0x07367 is a clean copy. It takes
three angles, builds a rotation matrix in locals, transforms six-byte
source-vertex records, and writes six-byte projected records.
The matrix setup reads table A/B for three angles:
07384: mov ax,[bx+4ee8h]
07388: cwde
0738a: mov [bp-04h],eax
0738e: mov ax,[si+4ee8h]
07394: mov [bp-08h],eax
07398: mov ax,[di+4ee8h]
0739e: mov [bp-0ch],eax
073a2: mov ax,[bx+5488h]
073a8: mov [bp-10h],eax
073ac: mov ax,[si+5488h]
073b2: mov [bp-14h],eax
073b6: mov ax,[di+5488h]
073bc: mov [bp-18h],eax
Then it precomputes matrix products with 32-bit signed multiplies:
073c0: mov eax,[bp-18h]
073c4: imul dword [bp-08h]
073c8: mov [bp-1ch],eax
073cc: mov eax,[bp-0ch]
073d0: imul dword [bp-08h]
073d4: mov [bp-20h],eax
...
07452: mov eax,[bp-1ch]
07456: imul dword [bp-10h]
0745a: sar eax,7
0745e: add eax,ecx
07461: mov [bp-3ch],eax
Per vertex:
07495: push ds
07496: mov es,[bp+0a] ; source segment
07499: mov ds,[bp+06] ; destination segment
0749c: mov ax,es:[si] ; x word
074a5: mov ax,es:[si+2] ; y word
074af: mov ax,es:[si+4] ; z word
...
074b9: mov eax,[bp-48h]
074bd: imul dword [bp-24h]
074c4: mov eax,[bp-4ch]
074c8: imul dword [bp-30h]
074cf: mov eax,[bp-50h]
074d3: imul dword [bp-3ch]
074da: sar ecx,5 ; rotated x
...
0750b: mov eax,[bp-48h]
0750f: imul dword [bp-2ch]
07516: mov eax,[bp-4ch]
0751a: imul dword [bp-38h]
07521: mov eax,[bp-50h]
07525: imul dword [bp-44h]
0752c: sar ecx,0eh
07530: add ecx,[bp+0e] ; z bias
07534: mov [bp-5ch],ecx
Projection is a signed divide by z + 0x200, followed by screen-center add:
07538: mov eax,[bp-54h] ; transformed x
0753c: add ecx,0200h
07557: idiv ecx
0755a: add ax,[bp+14h] ; center x
0755d: mov [di],ax
0755f: mov eax,[bp-58h] ; transformed y
07567: add ecx,0200h
07582: idiv ecx
07585: add ax,[bp+12h] ; center y
07588: mov [di+2],ax
0758b: mov eax,[bp-5ch] ; depth
0758f: mov [di+4],ax
07592: add si,6
07595: add di,6
07598: dec word [bp+4]
0759d: jmp 0749c
This is a straightforward fixed-point object projector. It favors signed 32-bit math over lookup-only hacks, but the final projected record is compact:
+0 word screen x
+2 word screen y
+4 word depth / z
12-Byte Object Transform
The larger mesh path uses 12-byte vertex records. The transform entry at
0x6d05 reads a sine/cosine table pair through far pointers, masks angles, and
then loops over dword vertices:
06d14: mov dx,[4e16] ; angle mask/range
06d18: les di,[4e0e] ; trig table A
06d1c: lds si,[4e12] ; trig table B
06d20: bx=[bp+16] & dx
...
06d68: lds si,[bp+22] ; source vertices
06d6b: les di,[bp+1c] ; destination vertices
06d71: ; loop count at [bp+18]
Each vertex is three dwords. The routine subtracts an origin/camera, rotates through 32-bit matrix products, shifts down, and writes three dwords:
06d72: mov eax,[si] ; x
06d77: mov eax,[si+4] ; y
06d7c: mov eax,[si+8] ; z
...
06da1: imul ...
06e5b: mov es:[di+8],eax ; transformed z/depth
06e60: add si,000ch
06e63: add di,000ch
This path feeds the face sorter described below. It is the path that explains
VRVERTEX.XXX dividing exactly into 901 12-byte fixed-point vertices.
Gradient Triangle Filler
The filler at 0x2080 is a byte-color, Gouraud-like triangle rasterizer. It is
not a texture mapper. It sorts three vertices by y, computes 16.16 edge slopes
and color slopes, clips to the 0..199 and 0..319 screen bounds, and then writes
one byte per pixel.
The sort/setup section is classic compiled scan conversion:
02091: mov eax,[bp+26h] ; vertex/attribute 0
02095: mov ebx,[bp+22h]
...
020a9: cmp ebx,[bp-08h]
020ad: jle 020c3
020af: xchg ebx,[bp-08h] ; sort by y
020b3: xchg eax,[bp-04h]
...
020fc: sub eax,ecx ; delta x
02100: shl eax,10h
02108: idiv ecx ; dx/dy in 16.16
The span hot loop is tiny:
02263: mov eax,[bp-06h]
02267: sar eax,10h ; left x
02273: mov ecx,[bp-0eh]
02277: sar ecx,8 ; left shade/color
...
02283: cmp eax,ebx
02288: xchg ebx,eax ; ensure left <= right
0228a: xchg ecx,edx
...
022ec: mov es:[di],dh ; pixel = high byte of shade accumulator
022ef: add dx,ax ; shade += dshade/dx
022f1: inc di
022f2: dec bx
022f3: jne 022ec
The accumulator choice is important. DX is a 16-bit shade accumulator and AX
is the per-pixel shade step. Writing DH means the integer color comes from the
high byte while the low byte carries sub-pixel/sub-color fraction. That gives
smooth palette gradients with almost no inner-loop work:
for x in span:
framebuffer[x] = shade >> 8
shade += shade_step
There is a clipped variant immediately after the main path. It uses the same
mov es:[di],dh / add dx,ax loop, but with x-boundary tests before entering the
span. This is a good sign that the routine was written for real use, not just a
happy-path polygon demo.
Planar VGA Span Filler
The routine around 0x3900 is a separate flat-color polygon path for unchained
VGA. The inner loop is built around Sequencer Map Mask writes, not chunky linear
addressing.
After edge interpolation and clipping, it turns (x,y) into a planar byte
offset:
03b93: mov di,[bp-1ah] ; y
03b98: shl di,6
03b9b: shl cx,4
03b9e: add di,cx ; y*80
03ba2: shr bx,2 ; byte address = x / 4
Then it handles start and end plane masks:
03bac: and cx,0303h
03bb4: mov ax,0ff02h ; sequencer index 2, mask in AH
03bb7: shl ah,cl ; start mask
03bbb: mov bh,0f1h
03bbd: rol bh,cl ; end mask
03bc7: mov dx,03c4h
03bca: out dx,ax ; select start plane(s)
03bcc: mov al,[bp+6] ; flat color
03bcf: stosb
The middle bytes select all four planes and use REP STOSW:
03bd5: mov al,0fh
03bd7: out dx,al ; all planes
03bdd: shr cx,1
03be4: rep stosw
The end byte restores the trailing mask and writes one byte:
03be6: mov al,bh
03be8: out dx,al
03bec: mov es:[di],al
This is a proper Mode X style span filler:
byte_offset = y * 80 + x / 4
start_mask = planes touched by first byte
middle_mask = 0x0f
end_mask = planes touched by last byte
It is slower to reason about than chunky mode, but it gives page/plane control and cheaper full-width planar fills once the masks are set.
Chunky Convex Quad Filler
The routine at 0x8f80 fills a convex four-point polygon in a chunky 64 KB
buffer. It walks four edges, finds the minimum and maximum x for each scanline,
clips, and then writes an aligned span.
The per-scanline edge merge is:
08fda..09083: compare four edge accumulators
choose min x and max x for current y
09083: cmp ax,013fh ; clip left/right to 0..319
0908c: cmp bx,013fh
0909b: mov si,di ; save row pointer
0909d: mov cx,bx
0909f: sub cx,ax
090a1: inc cx ; span length
090a4: mov eax,[bp-4ah] ; color replicated across dword
The store path peels byte/word edges until the pointer and length are aligned,
then falls into REP STOSD:
090aa: test di,1
090b0: mov es:[di],al
090b7: cmp cx,2
090c2: mov es:[di],ax
090cd: shr cx,1
090d2: shr cx,1
090d4: rep stosd
090d9: mov es:[di],ax
090e3: mov es:[di],al
090e7: mov di,si
090e9..09134: update four edge accumulators
09137: add di,0140h ; next 320-byte row
This is the fastest flat fill in the demo: one color, chunky destination, and a dword store for the body of the span. It complements the planar filler rather than replacing it. Different parts use different memory/display strategies.
Mesh Object Pipeline
The part at 0x464b loads the smaller object files:
faceface.xxx
facevert.xxx
bak1.srx
It initializes the planar mode path, allocates object/sort buffers, loads the files through runtime helpers, and then repeatedly transforms and draws faces.
The face-depth builder is the key loop. For each face, it reads four one-based vertex indices, converts each to a transformed vertex offset, averages the four depths, and stores a sort record:
047a8: ; face loop
047d6: mov ax,es:[bx+di] ; index 0
047dd: dec ax
047e1: ; vertex offset = index*12
047e9: mov eax,es:[bx+si+8] ; transformed z/depth
...
0482f: mov eax,es:[bx+si+8] ; fourth vertex depth
0483d: sar edx,2 ; average depth
04845: mov es:[di],ax ; face index
0484e: mov es:[di+2],edx ; average depth
The sort call at 0x485b takes that list:
0485b: les di,[217a]
04861: push 01f3h
04864: push [20f4] ; face count
04868: lcall 08de:051e ; runtime/sort helper
Drawing is grouped by the face record's +0x0a pass selector:
048aa: imul ax,[2202],000eh ; face index * 14
048b5: mov ax,es:[di+0ah] ; pass/bucket
048b9: cmp ax,[220c]
048bd: je 048c2
For each accepted face it fetches four transformed vertices and the color byte:
048da: mov ax,es:[bx+di] ; vertex 0 index
048e1: mov ax,es:[bx+di+2] ; vertex 1 index
048e9: mov ax,es:[bx+di+4] ; vertex 2 index
048f1: mov ax,es:[bx+di+6] ; vertex 3 index
048f9: mov ax,es:[bx+di+8]
048fd: mov [21e0],al ; color/material byte
It then pushes two triangles into the polygon drawer:
04599: ; draw quad as two triangle calls
045a3..045dd: push vertices 0,1,2 + color + segment
045e0: call 4041
045e3..0461d: push vertices 2,3,0 + color + segment
04620: call 4041
So this object renderer is:
load vertices/faces
transform vertices
for each face:
average four z values
sort face list by average z
for pass bucket 1..N:
for sorted face in bucket:
fetch four projected vertices
draw as two flat triangles
It is a painter's algorithm renderer. There is no z-buffer evidence. The per-face average is cheap and adequate for mostly convex demo objects.
Table/Tunnel Part
The part at 0x75db is tied to the table-style resources: OFF*.SSS,
SQRT.TAB, FRACT.LYS, DEC.RPL, POINTS.SAV, and the small .RAW
textures. The code first allocates several blocks, loads the data, and then
normalizes or scales 64,000-byte buffers.
One setup loop divides a whole screen-sized byte table by three:
076b4: xor di,di
076b6: mov cx,0f9ffh
076bb: mov al,es:[di]
076be: xor ah,ah
076c0: mov bl,03h
076c2: div bl
076c4: mov es:[di],al
076c7: inc di
076c8: loop 076bb
Then it builds a muted red/gray palette ramp by calling the single-DAC-entry helper:
076e9: mov ax,[bp-02h] ; i
076f0: push ax ; palette index
076f3: push ax/2 ; one channel half intensity
076f8: push ax/2
076fd: push ax/2
07700: lcall 0d77:00e6 ; DAC entry write
07704: cmp [bp-02h],003fh
07709: jne 076e9
Another loop multiplies the same table back by three:
07717: xor di,di
07719: mov cx,0f9ffh
0771e: mov al,es:[di]
07721: mov bl,03h
07723: mul bl
07725: mov es:[di],al
07728: inc di
07729: loop 0771e
The helper at 0x730e converts a 320-wide buffer into a 256-wide addressable
surface by copying only x=0..255 for each of 200 rows:
07330: mov ax,[bp+4]
07334: imul ax,[bp-4],0140h ; source y*320
07339: add ax,[bp-2] ; + x
0733f: mov dl,es:[di]
07346: mov ax,[bp-4]
07349: shl ax,8 ; destination y*256
0734c: add ax,[bp-2]
07352: mov es:[di],dl
07355: cmp [bp-2],00ffh
0735c: cmp [bp-4],00c7h
That is useful for tunnel math because y*256+x is just a shift and add. The
offset tables can then index a 256-wide texture or displacement map without a
multiply in the inner loop.
The exact final table-compositor loop is split across nearby helpers, but the data shape is clear:
OFF1.SSSandOFF2.SSSprovide per-pixel offsets/phases.SQRT.TABprovides a distance or radial term.TUNNEL.SRXand the 64x76.RAWfiles provide material/texture bytes.0x730erepacks 320-wide data to 256-wide for faster indexing.- Palette ramps are built directly through VGA DAC writes.
So the tunnel/displacement part is table-driven, not raytraced per frame. It pays the cost up front in 64 KB lookup maps, then the frame loop can combine phase counters and byte-table loads.
Title and Static Parts
The part around 0x5137 is a static/title presentation path. It sets palette
entries, selects VGA segment A000h, calls the image loader with a filename
near the title resources, waits, and uses the palette fade helper at 0x4d48.
The important pattern:
05137: ; setup
...
mov word [25fa],0a000h
call 04c00 ; SRX/image load path
call 04d48 ; palette interpolation/fade helper
The OTE4.PCX title image is not loaded through this SRX function, so there is
also a PCX path elsewhere. The visible static pieces are therefore:
OTE4.PCX: title card.NEW3.SRX/SORROX.SRX: Sorrox logo imagery.BAK1.SRX: background plate for object/logo parts.ENDPART.PCX: final screen.
The palette helper at 0x4d48 is high-level compiled code wrapped around the
DAC routines. It calls runtime math to interpolate channel values, then writes
them through the direct DAC helpers. It is not a hot pixel loop; it is transition
glue.
What Each Visible Part Is Doing
The exact timeline is controlled by far calls from the main entry and by music sync/timing helpers, but the file and code layout separate the demo into these functional parts:
-
Startup/system check. The runtime initializes, checks CPU class and memory, reads the
ULTRASNDenvironment, starts the GUS path, loadsOLKVER.MOD, and enters graphics mode. -
Title/logo images. The PCX/SRX loaders upload pre-rendered title/logo screens and their palettes. The transition work is palette fades through VGA DAC writes.
-
Gradient/vector object effects. Compact six-byte vertex records are rotated with the 720-entry trig tables, perspective-divided by
z+0x200, and rasterized by the byte-gradient triangle filler at0x2080. -
Planar mesh object. The
FACEFACE.XXX/FACEVERT.XXXpath enters a tweaked planar VGA mode, transforms compact source vertices into 12-byte in-memory records, averages face depths, sorts faces, and draws each quad as two flat triangles with the Mode X span code. -
Larger mesh objects.
APE*.XXXandVR*.XXXuse the same transform/sort/draw architecture but not necessarily the same disk record width.VRVERTEX.XXXis exactly 901 12-byte fixed-point vertices; the APE and face vertex files are compact six-byte word-vertex streams. The renderer expands transformed vertices into the 12-byte in-memory layout needed by the painter-sorted polygon pass. -
Tunnel/displacement/table effects. The 64 KB
OFF*.SSSandSQRT.TABfiles are precomputed per-screen lookup tables. The setup code repacks 320-wide buffers into 256-wide surfaces and builds palette ramps. The frame loop can then be mostly byte-table address arithmetic. -
End screen. The final PCX is a static 640x480 4-plane screen, with final palette/display handling rather than a realtime effect loop.
Why It Feels Fancy
Over The Edge is not fancy because it has one outrageous inner loop. It is
fancy because it mixes several competent 1995 PC demo techniques in one
real-mode system:
- Borland-style high-level file/runtime code for loading and sequencing.
- Direct GUS/MS-DOS setup instead of a generic multimedia layer.
- Direct VGA DAC, retrace, CRTC, and Sequencer programming.
- Both chunky 64 KB buffers and true planar Mode X drawing.
- 386 32-bit fixed-point geometry in a 16-bit executable.
- Painter-sorted quad meshes using 12-byte transformed vertices and 14-byte in-memory face records.
- Separate flat, gradient, planar, and table-driven render paths.
That mix also explains why the binary is harder to summarize than a single-part intro. The codebase is a small demo system: image loaders, palette fades, geometry transforms, multiple rasterizers, file-backed lookup tables, and part-specific setup code all coexist in one 73 KB segmented MZ executable.