Analysis model: gpt-5.5 xhigh
E:XTRA by The Serpent - Technical Dissection
Scope
E:XTRA is The Serpent's MS-DOS demo from The Gathering 1994. The result file
for The Gathering 1994 lists the PC demo ranking by points:
815 : Five "Superunknown"
383 : The Serpent "E:XTRA"
297 : Xpose "Icefever"
193 : The Interiors "Back to basic"
Release year: 1994. The archive timestamps are 1994-03-22 through 1994-04-02, and the Exile release description bundled with the archive identifies it as the second-place PC demo from The Gathering 1994.
Public references:
- Scene.org TG94 results: https://archive.scene.org/pub/parties/1994/thegathering94/results.txt
- Scene.org party archive: https://archive.scene.org/pub/parties/1994/thegathering94/demo/extra.zip
- Demozoo The Gathering 1994 page: https://demozoo.org/parties/40/
The analysis below uses the party archive. The Exile release description also contains period distribution/contact details; those private details are intentionally not reproduced here.
Offset notation:
DEMO.EXE+0x...means a file offset in the MZ executable.image+0x...means an offset in the EXE image after removing the 1,136-byte MZ header.- Far pointers such as
01ac:135dare converted assegment * 16 + offsetwhen referring to physical offsets inside the loaded image.
Examined Files
Archive identity:
2caa13bce10712ea9241c66ee7d43dcd8d274b5f6cea9c0b1721607484ebc24a extra.zip
778c42886e96d0bcf54e2d13deff4edcda8190d8c1b528e99a1e488d17354992 tg94-results.txt
Archive contents and extracted hashes:
DEMO.EXE 28,336 bytes 559f7a423608132b3fd14803f071931c1c29cbc00d5d090854d833630a55e454
EXILE.DEM 3,764 bytes 38a3bc8e0123acd3da6fffdce60a608826be9d277412a8f19577d59d2b342912
LOGO1.GRF 12,964 bytes bfb9349b152997aed8452731f4406eb8ad05724e27eb6bddd9f13d23bf8fb41f
LOGO2.GRF 11,785 bytes 776a508cb535ee2cdf9396d934530935202a3d8f167b3c036da79b1cadbb46ff
LOGO3.GRF 6,208 bytes 85d5ea9455d67a3a1fffe0dccf0ae4f2089c30ede50a2266e040163e237790cd
LOGO4.GRF 30,052 bytes 138734dc42270cc04e6863981d9836ccc688e4d7c36bb8eb78f3d2491358fcc8
POS.DAT 5,000 bytes 166bba0caeaea09d315c2e854713511758f44ac1685c6d4f0a12bc9fe5fa5eee
WALLTEX.GRF 21,454 bytes c57acf25a4096e7c3762f6ce4021d1a37f28741bc9a4f0c4edeb14171d750282
WORLDMAP.GRF 26,823 bytes b688b5adbaf39b41b5a745663f6d99c6bcea9f8e19984de587b10589935b1520
File roles:
DEMO.EXE real-mode MS-DOS MZ executable, Borland/Turbo Pascal runtime
WALLTEX.GRF packed 320x200 BV2 image containing four 64x64 wall textures
WORLDMAP.GRF packed 320x200 BV2 world map picture
LOGO*.GRF packed 320x200 BV2 logo/screens
POS.DAT 1,000 five-byte camera/path records
EXILE.DEM release description wrapper, not part of the runtime
DEMO.EXE is not packed by PKLITE/LZEXE. The MZ header is ordinary:
file size: 28,336 bytes
MZ header: 1,136 bytes
relocations: 275
image size: 27,200 bytes
entry point: CS:IP 0000:0c0f
entry file off: 0x107f
stack: SS:SP 1466:4000
The entry calls several Borland runtime startup helpers, then reaches the
demo's Pascal main procedure around image+0x0c2d.
High-Level Run
The main sequence is simple and very 1994 PC:
- Print the loading text in text mode.
- Decode
WALLTEX.GRFinto a temporary 320x200 buffer. - Slice the top strip of
WALLTEX.GRFinto four 64x64 textures. - Build four darker/alternate 64x64 texture copies by remapping palette indices through a nearest-color table.
- Load
POS.DAT, enter mode 13h, and run the interactive/path-playback texture-mapped scene. - Decode and show three logo screens, with palette fades between them.
- Return to text mode.
There is no music path. The bundled release wrapper explicitly states that no sound is supported, and the executable contains no tracker player setup.
BV2 Image Format
All .GRF files begin with:
42 56 32 "BV2"
40 01 width = 320
c8 00 height = 200
ff palette-present marker
For BV2 files with marker ff, the next 0x300 bytes are VGA DAC palette
triples. The packed pixel stream then stores one row at a time.
The row decoder is at image+0x3eed. It first opens the file, fills a 4 KB
read buffer, checks BV1/BV2, reads width/height, and accepts only marker
0x0f or 0xff. For marker 0xff in BV2, it reads 256 RGB triples into
ds:db2e. If the caller asked for palette upload, it calls the vblank-gated
palette uploader at image+0x4432.
The scanline body has two modes. A row byte of ASCII P means packetized RLE:
411e read row mode byte
4128 cmp mode,50h
4132 x = row_start
4142 read color byte
414c read run length low byte
4156 read run length high byte
4173 run_len = low + high*256
4177 if color != 0 or transparent_copy_is_off:
4184 dest = framebuffer + y*320 + x
4194 fill dest with color for run_len bytes
41a4 x += run_len
41ab repeat until x passes row_end
If the row mode is not P, that mode byte is not a pixel. It merely selects
raw-row mode; the decoder then reads exactly 320 pixel bytes for the row:
41c1 x = row_start
41cb read one pixel byte
41d5 if pixel != 0 or transparent_copy_is_off:
41e2 framebuffer[y*320 + x] = pixel
41fa x++
420d repeat through the row
This interpretation was checked by a local decoder: all six GRF files decode
to exact EOF as 320x200 images. The decoded WALLTEX.GRF top strip contains a
red brick tile, a white symbol on black, a blue noise tile, and a white symbol
on blue. The rest of that image is mostly black.
Mode, Timer, Palette
The small local mode helpers are at the start of the image:
0040 mov ax,0013h
0043 int 10h
0045 ret
0046 mov ax,0003h
0049 int 10h
004b ret
Two very small timer wait loops exist. The first is image+0x001d/0x002d,
using a far timer handler at image+0x001d that increments ds:04b0. The
second copy is image+0x0dad/0x0dbd, using ds:07c2. Both are the same
pattern:
handler:
inc word [frame_counter]
iret/retf through the interrupt wrapper
wait_one_tick:
cmp word [frame_counter],0
jbe wait_one_tick
The lower timer layer around image+0x4520 installs an INT 08h replacement and
uses INT 78h as the old-timer trampoline. PIT channel 0 is programmed through
ports 43h and 40h:
454d mov al,36h
454f out 43h,al
4553 mov cx,[de42] ; divisor
4559 out 40h,al ; low byte
455f out 40h,al ; high byte
4566 irq0 handler enters
4575 add [de44],cx
457b out 20h,20h
4589 optional per-tick far callback
4592 iret
4593 int 78h ; chain to saved timer path when needed
Palette upload is carefully gated to VGA status:
443c cli
443d dx = 03dah
4440 wait while vertical retrace bit is set
4445 wait until vertical retrace bit becomes set
444a sti
444c dx = 03c8h, al = 0
4451 out dx,al ; start DAC index 0
4459 for each of 768 bytes:
445c wait for display-enable edge on 03dah bit 0
4466 dx = 03c9h
4469 lodsb
446a out dx,al
The palette fades use the same uploader. image+0x42d3 builds 31 intermediate
palettes by multiplying each DAC channel by a step and dividing by 0x1f, then
uploads each one. image+0x4224 does the reverse: it decrements each channel
toward zero and uploads each intermediate palette.
Texture Preparation
image+0x01ba loads WALLTEX.GRF into a 64,000-byte heap buffer, then copies
four 64x64 tiles into an 0x8000-byte heap block:
01c8 allocate 0xfa00 bytes for decoded image
022c decode "walltex.grf" into that image
0231 allocate 0x8000 bytes for texture pages
0240 y = 0
024a x = 0
0254 source = decoded[(y+1)*320 + (x+1)]
0273 dest = texture0[y*64 + x]
0281 repeat x through 63
0287 repeat y through 63
The same double loop is repeated with source x offsets 0x41, 0x82, and
0xc3, storing into +0x2000, +0x4000, and +0x6000. After that:
texture0 +0x0000 source x 1..64
texture1 +0x2000 source x 66..129
texture2 +0x4000 source x 131..194
texture3 +0x6000 source x 196..259
It then duplicates each tile into the odd 4 KB half after it:
03dc copy texture0 +0x0000 to texture0 +0x1000
03f4 copy texture1 +0x2000 to texture1 +0x3000
0410 copy texture2 +0x4000 to texture2 +0x5000
042c copy texture3 +0x6000 to texture3 +0x7000
The duplicated copies are palette-remapped through image+0x00c7, using a
70 percent brightness scale. The remapper first builds a 256-byte lookup table:
00e7 for palette index 1..255:
00f7 read source RGB from palette table
0113 channel = channel * 70 / 100
0146 nearest = find_nearest_palette_color(channel_rgb)
014a remap[index] = nearest
find_nearest_palette_color at image+0x004c is not Euclidean; it uses
Manhattan distance across RGB:
0063 read candidate r
0066 abs(candidate_r - target_r)
006d read candidate_g
0071 abs(candidate_g - target_g)
0078 add to distance
007a read candidate_b
007e abs(candidate_b - target_b)
0085 add to distance
00b7 if distance < best: remember index
00bf repeat through 190 candidates
The pixel remap pass then walks the target block and replaces each pixel with
remap[pixel]. That gives the renderer two versions of each 64x64 wall panel:
one normal and one darker.
Path Data And Movement
POS.DAT is a 1,000-record table. Each record is five bytes:
uint16 x
uint16 z
uint8 angle
The first records show the demo starting at x/z 96,96 with angle 128,
then moving forward in z:
01 x= 96 z= 96 angle=128
02 x= 96 z= 96 angle=128
03 x= 96 z= 96 angle=128
04 x= 96 z=100 angle=128
05 x= 96 z=108 angle=128
The scene loop at image+0x08bf supports both playback and live movement:
09d1 allocate 0x09c4 bytes for POS.DAT
09df load pos.dat into that buffer
09e3 read saved positions
0a20 frame loop starts
0a26 if playback is active:
0a2b record_offset = index*5
0a36 x = record.word0
0a40 z = record.word1
0a47 angle = record.byte4
0a4e render one frame
0a53 wait one tick
0a6b add consumed ticks to local accumulator
When not in playback, keyboard state bytes at ds:de5a..de5f feed turning and
forward/back movement. The turn velocity is stored on the stack at bp-0x9e;
it accelerates by eight while a turn key is down and decays by four otherwise:
0a80 if key_right and turn_velocity < 16: turn_velocity += 8
0a93 if key_left and turn_velocity > -16: turn_velocity -= 8
0ab4 if neither key:
0abb if turn_velocity < 0: turn_velocity += 4
0ac9 if turn_velocity > 0: turn_velocity -= 4
0b3b angle += low_byte(turn_velocity)
Forward/back movement uses a smaller velocity at bp-0xa0, changing by four
while a movement key is held and decaying by two otherwise. The movement helper
at image+0x05e9 calculates sine/cosine-based deltas from the angle, adds them
to ds:4122 and ds:4126, then checks four corner points around the camera.
The corner radius is 0x18:
071a test x-18, z-18
0737 test x+18, z-18
0754 test x-18, z+18
0771 test x+18, z+18
0791 if any fails, roll back z movement first
0822 if still blocked, roll back x movement
08ad if still blocked, cancel vertical/speed part
The collision probe at image+0x05a2 maps world coordinates into a 32x32
cell map:
05b0 bx = x / 64 + 1
05bc ax = z / 64 + 1
05c8 map_index = (zcell * 32) + xcell
05cd tile = map[map_index - 0x1f]
05d1 return true if 5 <= tile <= 8, else false
So the playable world is a coarse 64-unit grid, not a free polygon world. The renderer builds walls from that grid each frame.
Projection And World Queue
The per-frame render call is 01ac:135d, physically image+0x2e1d:
2e27 build projected world points
2e2a transform map vertices into camera space
2e2d queue wall spans/sprites
2e30 copy dirty rectangle to visible screen
The transform stage at image+0x1bf4 uses a 512-entry sine table at ds:4130.
ds:4120 is the current byte angle; the angle plus 0x40 gives the perpendicular
axis. For each world point at ds:4330 + index*6, it subtracts the camera
position at ds:4122/4124/4126, rotates x/z, and performs a perspective-like
divide:
1c02 sine_table = 4130h
1c05 angle = [4120]
1c0d sin_angle = table[angle]
1c12 cos_angle = table[(angle+64) & 255]
1c31 dx = point.x - camera.x
1c3a dy = point.y - camera.y
1c44 dz = point.z - camera.z
1c4e screen_x_num = cos*dx - sin*dz
1c69 depth_num = sin*dx + cos*dz
1c84 if depth <= 0: choose far sentinel path
1cac projected_x = divide(screen_x_num, depth_scale)
1cb6 projected_y = divide(dy, depth_scale)
1cd6 store projected point at 5140h + index*6
The divide helper at image+0x1bd0 is defensive: if the divisor is zero, or if
the intermediate quotient would collapse to zero in the high-precision path, it
sets a sentinel byte at ds:898e. The caller then stores x/y as zero and depth
as 0x7d00, effectively pushing that point out of the draw set.
Map-To-Wall Expansion
image+0x2e35 is the map expansion pass. It receives:
texture record table
cell map
tile descriptor table
map width
map height
It scans the map cells in nested y/x order:
2e83 y = 0
2e95 x = 0
2eae tile = map[y*width + x]
2ec3 if tile == 0: skip
For each nonzero tile it checks the neighbor above, below, left, and right. If the neighbor is empty, or if the neighbor's descriptor says that side should not hide the face, the code queues a wall side. Every side queues two edge vertices, the texture pointer, texture width/height, and a normal/dark texture flag.
The north-side queue is representative:
2ef4 if y == 0: edge is visible
2efd if map[y-1,x] == 0: edge is visible
2f03 else if neighbor descriptor final byte != 0: hidden
2f18 if current descriptor north texture id == 0: skip
2f3b fetch north texture record
2f54 screen/world edge x0 = x*64 + 64
2f5e screen/world edge y0 = y*64
2f65 texture u/v endpoints = -32,32 / -32,32
2f7b push texture pointer, width, height, variant flag
2f90 queue a vertical wall span
The south, west, and east cases repeat the same shape with the expected
coordinate changes. Ceiling/floor-like center quads use a separate queue path
when descriptor bytes -5, -4, or -3 are present.
The important point is that E:XTRA does not raycast one screen column at a
time. It builds projected wall faces from a 32x32 grid and submits textured
quads/lines to a span queue.
Dirty Rectangle And Draw Ordering
The span queue uses two tables:
ds:5f50 projected point count
ds:5f52 queued draw item count
ds:8974... sorted draw items, 0x1c bytes each
ds:cb30... per-screen-column dirty y min/max pairs
At image+0x226c, projected x/y coordinates are first scaled by ds:5f5c
and centered at ds:5f54/5f56:
2281 point.x = point.x * zoom / 256 + center_x
2292 point.y = point.y * zoom / 256 + center_y
Then each queued draw item is clipped against the current screen rectangle
held in ds:044c..0452. Visible items update the per-column dirty y range.
The dirty range table is initialized to min/max 100,100 for columns 0..319:
2849 for x = 0..319:
284f dirty_min[x] = 100
285b dirty_max[x] = 100
For each visible item, the code computes a bounding box, skips it if it is fully
outside the viewport, and tightens dirty_min/dirty_max only for the columns
it touches:
2abf si = dirty_table + left*4
2aca cx = right - left + 1
2ad1 if new_top < dirty_min[x]: dirty_min[x] = new_top
2adc if new_bottom > dirty_max[x]: dirty_max[x] = new_bottom
2ae9 si += 4
2aec loop
After that, the queued items are drawn back-to-front. Item type 1 and 2
call the textured trapezoid/quad path at 033f:0000; item type 3 calls
033f:0262, the four-point polygon path.
Textured Span Inner Loop
The low-level vertical span renderer starts at image+0x37be. It is used by
the textured wall paths after they set source pointer, screen endpoints, texture
dimensions, and u/v endpoints in globals ds:d040..d056.
The setup computes fixed-point steps:
3842 count = x1 - x0 + 1
3847 du_dx = abs(u1-u0) << 16 / count
3880 dv_dx = abs(v1-v0) << 16 / count
38b1 source_step = texture_width << 16 / vertical_count
For every screen column, it calculates the visible y interval, clips against the screen top/bottom, and computes an initial source offset. The hot loop is vertical; it walks down the column in A000h:
39ab al = fs:[si] ; sample texture
39ae if al != 0:
39b4 es:[di] = al ; transparent zero
39b7 di += 320 ; next scanline
39bb dx += source_step_low
39c0 si += source_step_high + carry
39c2 loop
There is a doubled-pixel version for small source steps:
39ce al = fs:[si]
39d1 if al != 0:
39d7 es:[di] = al
39fa es:[di+320] = al
39ff di += 640
3a03 advance source accumulator
3a0a loop
That is the central visual loop of the demo: one transparent texture sample per vertical screen step, with source stepping in fixed point and destination stepping by VGA scanline pitch.
Screen Clear And Copy
The world scene is rendered into an off-screen buffer at ds:411a/411c, then
copied to A000h. The copy routine at image+0x1b29 uses the viewport rectangle:
1b37 width_words = ([0450] - [044c] + 1) / 4
1b43 row_count = [0452] - [044e] + 1
1b4f start = top*320 + left
1b63 ds = backing_buffer_segment
1b68 es = a000h
1b6d cx = width_words
1b6f rep movsd-equivalent helper
1b72 si += 320
1b78 si -= width_words*4
1b7d di = si
1b82 repeat row_count
The fill helpers use 386 operand-size prefixes in real mode:
33de shl eax,16
33e4 rep stosd
33e8 rep movsd
The Pascal code is otherwise ordinary 16-bit real-mode code, but these two helpers use 32-bit string operations for the bandwidth-critical fills/copies.
End Screens
After the world section exits, the main function returns to mode 13h and shows three BV2 screens:
0ccc decode logo2.grf
0cdf repeat vblank wait 0xe6 times
0d03 decode logo3.grf
0d18 repeat vblank wait 0xe6 times
0d3c decode logo4.grf
0d51 repeat vblank wait 0xe6 times
0d6e text mode
The map picture and first logo string are used by the earlier graphic sequence
around image+0x1163. That routine allocates two 64,000-byte buffers, decodes
the map/logo screens, and uses image+0x0e7d to apply a wave-like vertical
wipe: it clears horizontal spans to color 0xfe, uses a sine table at
ds:09dc, and copies scanlines from one buffer into another through
image+0x0dd6.
The line-copy helper at image+0x0dd6 stores a source pointer and geometry in
globals, then jumps into image+0x199e. That lower loop reads source pixels
through FS, darkens the low six color bits by a row-dependent table, preserves
the high two bits, and writes the result to A000h:
1a6a al = fs:[si]
1a6f al &= 3fh
1a71 al -= shade_table[si]
1a77 if negative: al = 0
1a79 ah = original & c0h
1a7c al |= ah
1a7e es:[di] = al
1a81 di++
1a82 source_fraction += step_fraction
1a84 si += step_integer + carry
1a89 loop
This is why the logo/map transition is not a plain image blit. It is a shaded, resampled scanline pass with wrapping source offsets.
Why This Fits The TG94 Slot
E:XTRA is a compact and technical second-place TG94 demo. It does not compete
with later 1995 productions on audio, protected-mode runtime, or asset volume;
instead it spends its code budget on a software 2.5D renderer:
- a custom BV2 RLE image format,
- vblank-synchronized palette upload and fades,
- 386
rep stosd/rep movsdhelpers inside real-mode Pascal code, - pre-sliced 64x64 texture banks,
- playback and live camera movement over a 32x32 collision map,
- projected grid-wall expansion rather than column raycasting,
- fixed-point textured vertical spans with transparent texels, and
- dirty-column tracking before the final screen copy.
That makes it a useful counterpart to Superunknown: both are The Gathering
1994 PC demo entries, but E:XTRA is much more about a single navigable
texture-mapped scene and the utility code needed to keep it moving on early
1990s VGA hardware.