Analysis model: gpt-5.5 xhigh
Drift by Wild Light - Technical Dissection
Scope
This is a static technical dissection of Drift by Wild Light, released for
MS-DOS at Assembly 1995. The Assembly archive lists it as the winner of the
Assembly 1995 PC 64K intro competition. The examined file is the public
drift.zip archive from scene.org.
Public references:
- Assembly archive: https://archive.assembly.org/1995/pc-64k-intro/drift-by-wild-light
- Scene.org archive: https://archive.scene.org/pub/parties/1995/assembly95/in64/drift.zip
- WWPACK package listing: https://www.infania.net/misc/simtelnet/msdos/execomp.html
- UNP executable unpacker: https://bencastricum.nl/unp/
This analysis is not a source-level reconstruction. It is a layered binary analysis: archive metadata, WWPACK unpacking, MZ loader structure, the protected-mode interrupt bridge, and several recovered 32-bit rendering loops.
Offset notation:
packed EXE+0x...means a file offset in the original 65,306 byteDRIFT.EXE.unpacked EXE+0x...means a file offset in the UNP-expanded 141,956 byte MZ file.- Absolute operands such as
ds:[0x2097c]are runtime image offsets from the recovered protected-mode program, not file offsets.
Credits And Runtime Contract
DRIFT.TXT identifies the intro as:
DRIFT by WILD LIGHT released at the Assembly'95 10-13.08.1995
The info file says the intro requires at least a 386 and 4 MB of memory, and recommends a 486/66 with a fast graphics card and a Gravis UltraSound. The player supports GUS, Sound Blaster, and Sound Blaster Pro.
The embedded end text gives the useful production-role map:
Odd Monk - wall texture, fire logo shape
Preacher - fonts, vector objects
Nobody - music
Asmu - player, fire logo, 3D Julia morpher
Vulture - waver, end scroller, greets writer, vector routines
Tran - PMODE
That role split matches the recovered code fairly well: a Tran-style protected-mode loader, an S3M-like music/player region, a shared vector object pipeline, a separate waver/greets writer, and a distinct end-scroller bitblitter.
Examined Files
Archive contents:
drift.zip 72,338 bytes
CALL_NOW.COM 3,995 bytes
DRIFT.EXE 65,306 bytes
DRIFT.TXT 6,250 bytes
FILE_ID.DIZ 89 bytes
scene.org 1,989 bytes
Important hashes:
25fd001fc62c9b48d6ff8dbea36de9b353cac7681b44027aed9f77e6f8a0ba1c drift.zip
935b472820abfa65e1789389c5f65d2139e301e5bc6f49d731550460afdb0efe DRIFT.EXE
4b1ce13a34f5c70ac9a9c3ec84fd61eb0c05cfa3e443db0566d57d8bd4268bcc DRIFT.TXT
1bbcb1c1d38c9c7130772b26168eeacf0280dead255685163d5c94e5ca2b74e0 FILE_ID.DIZ
The original executable is an MZ program identified by file as WWPACK compressed. The UNP-expanded executable used for the inner-loop pass is:
unpacked DRIFT.EXE size: 141,956 bytes
SHA-256: fc2cfbecbb08695a9a7d7c7833388329528489285986075bc326c3a904e4e863
UNP 4.11 was used under DOSBox-X. Its changelog says WWPACK support was fixed and WWPACK 3.02(a) support was added. This fits Drift's wrapper closely enough for the expanded file to recover the PMODE loader and intro body.
Packed Executable Layout
The packed executable is a tiny MZ image with a WWPACK bootstrap occupying the normal relocation-table area.
file size: 65,306 bytes
MZ image size field: 65,306 bytes
header size: 32 bytes
relocation count: 0
entry file offset: packed EXE+0x21
signature: packed EXE+0x1c = "WWP "
The original entry begins inside the WWPACK stub. In simplified form, its first job is to build a far return to the real unpacker and copy a small stublet downward through memory:
packed EXE+0x21:
mov ax,0x0feb
mov dx,cs
add dx,ax
mov cx,cs
add cx,0x22a1
push cx
push 0x0006
...
mov bp,ss
mov si,0x003a
copy_block:
dec bp
mov es,bp
mov ds,dx
dec dx
mov cx,0x0008
rep movsw
dec ax
jns copy_block
...
lodsw
xchg bp,ax
retf
The visible strings in this wrapper are already the later protected-mode
runtime messages: 386 or better not detected, 180KB, VCPI, A20,
DPMI, and Incompr!. That is a useful warning when reading the packed file:
some strings are visible, but the executable body is still compressed and
relocated. Disassembling the packed bytes past the stub produces misleading
code.
Unpacked MZ Layout
After UNP expansion, DRIFT.EXE becomes a 141,956 byte MZ executable.
file size: 141,956 bytes
MZ image size: 141,956 bytes
header size: 112 bytes
relocation count: 18
initial CS:IP: 0000:03fd
entry file offset: unpacked EXE+0x46d
initial SS:SP: 22a2:1c00
The recovered relocation table has only 18 entries. This is typical for a DOS extender image: the real-mode loader is small, then it builds descriptors and transfers control to a mostly flat 32-bit program.
The entry at unpacked EXE+0x46d starts as a real-mode bootstrap:
cli
cld
push cs
pop ds
call 0x03fb
mov ax,es
movzx eax,ax
shl eax,4
mov ds:[0x0ec0],eax ; PSP/host base
...
mov eax,0x22a2
shl eax,4
sub eax,ebx
mov ds:[0x0eb0],eax ; available high linear memory
...
int 2fh ; DPMI installation check, AX=1687h
The loader has three boot paths:
- Existing 32-bit DPMI host: call
int 2fh, AX=1687h, check it is 32-bit, allocate descriptors, and enter protected mode. - VCPI host under a memory manager: use VCPI services if V86 mode is active.
- Raw machine: enable A20 and build its own protected-mode state.
The A20 routine is concrete. It first tries port 0x92, then falls back to
the keyboard controller:
in al,0x92
or al,0x02
out 0x92,al
...
mov al,0xd1
out 0x64,al
...
mov al,0xdf
out 0x60,al
The test routine writes through low and high aliases using fs:0 and gs:10
to prove that A20 is really open. If the aliases still collide, the loader
prints Couldn't enable A20 gate!!!.
Protected-Mode Interrupt Bridge
The recovered 32-bit code uses int 33h frequently. In this intro those are
not mouse API calls. They are calls into the protected-mode runtime's real-mode
interrupt bridge.
The pattern is visible in the mode changes and DOS string printer:
; Set text mode 03h
mov word [0x00dc],0x0003
mov al,0x10
int 0x33
; Set graphics mode 13h
mov word [0x00dc],0x0013
mov al,0x10
int 0x33
; Print a "$"-terminated DOS string
; EAX contains a flat pointer first.
add eax,[0x18]
shld edx,eax,0x1c
and eax,0x0f
mov byte [0x00dd],0x09
mov word [0x00d4],ax
mov word [0x00e4],dx
mov al,0x21
int 0x33
So the low-memory block around 0x00d4..0x00e4 is a real-mode register frame.
AL selects the real-mode interrupt to reflect. This matters for reading the
code: AL=10h means "reflect BIOS video interrupt 10h", and AL=21h means
"reflect DOS interrupt 21h".
The other important runtime variable is ds:[0x18]. VGA pointers are formed
as:
mov edi,0x000a0000
sub edi,[0x18]
That is the runtime's flat-address correction for physical video memory. When
code writes to 0xa0000 - [0x18], it is writing the VGA aperture.
Startup, Menu, And Main Timeline
The intro body begins after the embedded error strings around
unpacked EXE+0x22238. Its top-level sequence is:
call 0x222c5 ; keyboard/PIC/video initialization
call 0x22763 ; first flash/fade/fire-logo phase
call 0x227b3 ; palette-morphed vector/textured phase
call 0x227e8 ; waver/greets phase setup
call 0x22829 ; vector/morph phase loop
call 0x22864 ; waver + vector loop
call 0x228a9 ; final vector/waver transition
call 0x1e4ff ; end scroller
wait 0x1300 ticks
call 0x2264f ; cleanup
set text mode, copy end text to B8000, return to DOS
Before the graphics begin, it draws text-mode configuration screens directly
to B8000h. For example:
mov edi,0x000b8000
sub edi,[0x18]
mov esi,0x0001d840
mov ecx,0x0258
rep movsd
The keyboard menu loop at 0x2269e watches raw scancodes from port 0x60:
48h up
50h down
1Ch enter
01h escape
The selected sound card, IRQ, DMA, and port are stored in small state variables
around 0x20954..0x2095a. The sound-player calls go through call 0x34e4.
The static pass identifies this as the player/service gateway, but does not
fully reconstruct the player. The embedded messages Sound card not found!
and Module in DRIFT.EXE is corrupted! are at unpacked EXE+0x221fb.
Timer IRQ And Part Dispatch
The intro reprograms PIT channel 0:
cli
mov al,0x36
out 0x43,al
mov al,0x97
out 0x40,al
mov al,0x42
out 0x40,al
sti
The divisor is 0x4297, which is about 70.0 Hz from the 1,193,182 Hz PIT
clock. The IRQ body at 0x228f0 is the central timing loop:
pushad
push ds
push es
load runtime DS/ES
inc dword [0x209a0] ; global frame/tick counter
mov al,0x04
and ax,[0x20954] ; only if sound/player is enabled
call 0x34e4 ; player tick/service
mov ebx,[0x2097c] ; current phase selector
add ebx,0x20980
mov ebx,[ebx] ; callback from dispatch table
call ebx
send PIC EOI
pop es
pop ds
popad
iret
This explains a lot of the intro's organization. The foreground code is a
script that sets ds:[0x2097c] to values such as 0x08, 0x0c, 0x10,
0x14, 0x18, or 0x1c. The timer interrupt keeps audio and background
animation alive by dispatching the per-phase callback.
VGA Mode And Page Control
The intro uses both linear chunky writes and planar VGA tricks. The most
explicit tweaked-mode setup is at 0x1c9ef:
mov dx,0x03d4
mov ax,0x0014
out dx,ax ; CRTC underline/location: doubleword addressing off
mov ax,0xe317
out dx,ax ; CRTC mode control
mov ax,0x0109
out dx,ax ; maximum scanline
mov dx,0x03c4
mov ax,0x0604
out dx,ax ; sequencer memory mode: unchain/odd-even control
Plane selection is centralized:
0x1df14:
and ah,0x0f
mov edx,0x03c4
mov al,0x02
out dx,al
inc edx
mov al,ah
out dx,al
ret
Display-start changes write CRTC registers 0Ch and 0Dh:
mov edx,0x03d4
mov al,0x0c
mov ah,bh
out dx,ax
inc al
mov ah,bl
out dx,ax
So the intro does not merely paint pixels and wait. It repeatedly changes VGA addressing, map masks, and start addresses to get page flips, planar clears, and scrolling without always moving a full 64 KB.
Palette Lerp Loop
The palette interpolator at 0x22984 is one of the cleanest shared inner
loops. Inputs are:
ESI = source palette bytes
EDI = target palette bytes
EAX = current step
EBX = total step count
ECX = number of bytes to write, usually 0x300
The setup computes two 16.16 fixed-point weights:
mov [0x212b9],ecx
mov ecx,eax
neg eax
add eax,ebx
shl eax,16
xor edx,edx
div ebx
mov ebp,eax ; source weight
mov eax,ecx
shl eax,16
xor edx,edx
div ebx
mov ebx,eax ; target weight
Then it synchronizes to vertical retrace and writes the DAC:
mov edx,0x03da
wait_not_vblank:
in al,dx
test al,0x08
jz wait_not_vblank
wait_vblank_end:
in al,dx
test al,0x08
jnz wait_vblank_end
mov edx,0x03c8
xor al,al
out dx,al
mov ecx,0x20fb9 ; cached current palette
loop:
movzx eax,byte [esi]
imul ebp
mov edx,eax
movzx eax,byte [edi]
imul eax,ebx
add eax,edx
shr eax,16
mov dx,0x03c9
out dx,al
mov [ecx],al
inc ecx
inc esi
inc edi
dec dword [0x212b9]
jnz loop
This is why so many transitions in Drift look continuous despite the 64K budget. The visual phase code often changes only palette tables and lets this routine do the expensive perception work.
Fire / Plasma Filter
The first large visual phase calls 0x10deb. It clears a 64 KB work buffer,
loads a 0x2fa-byte palette to DAC entries starting at index 1, injects random
energy, then repeatedly runs a four-neighbor decay filter.
The spark injection routine at 0x10f70 is table-driven. It uses a small
pseudo-random state built from three 16-bit constants:
mov bx,0x1234
mov cx,0x5678
mov ax,0x9abc
xor ebx,ecx
rol ax,cl
xor ecx,eax
add ax,dx
add bx,ax
add cx,bx
For each entry selected by the table at 0xef30, it computes a target address
inside the work buffer and writes a seed value one scanline below it:
movzx edi,word [esi]
add edi,[0xfe62] ; work-buffer base
mov ax,[edi]
sub ax,cx
shr ax,2
mov [edi+0x140],ah ; next line, 320 bytes ahead
The filter itself starts at 0x10ece. It switches ES to the VGA selector and
DS to a work-buffer selector, then processes approximately 176 visible rows.
Each row handles 26 inner iterations, and each iteration emits two dwords,
which is 8 chunky pixels. The add edi,0x70 at the end of the row skips the
remaining 112 bytes so the stride is exactly 320:
mov cx,0x1a ; 26 groups per row
...
; first 4-pixel group
mov ebp,[di-4]
mov eax,[di+0x13c] ; neighbor 316 bytes ahead
add eax,ebp
mov edx,[edi]
shrd ebp,edx,8
add eax,ebp
shrd ebp,edx,8
add eax,ebp
and eax,0xfcfcfcfc
shr eax,2
sub eax,0x01010101
test eax,0xc0c0c0c0
je no_underflow_1
add eax,0x01010101
no_underflow_1:
stosd
mov [edi+ebx],eax
; second 4-pixel group, same idea with shifted neighbor state
...
This is a packed 4-byte-at-a-time fire/plasma update. The and 0xfcfcfcfc
before the shift prevents cross-byte carry from contaminating adjacent pixels.
The subtract by 0x01010101 adds decay. The test 0xc0c0c0c0 branch is an
underflow check: if a byte wrapped into the high bits, the code cancels the
decay for that dword.
The visual result is a classic 1995 PC optimization: each dword carries four independent pixels, and the row math is arranged so only a few memory loads and shifts are needed per eight output pixels.
Vector / Julia Morph Pipeline
The shared object pipeline begins at 0x1c318 and 0x1c348. It processes
object records in 0x40-byte blocks terminated by a leading 0xff.
The high-level frame path is:
0x1c318:
esi = 0x14dbd
[0x100f8] = esi
call 0x11c30 ; build current transform terms
call 0x11e90 ; transform and project vertices
call 0x11f60 ; transform auxiliary vertex data
call 0x12480 ; depth/intensity calculation
call 0x12043 ; collect and split visible faces
call 0x12530 ; draw sorted faces/spans
Several apparent imul reg,eax,0 instructions in the static disassembly are
not dead code. The code writes current matrix and interpolation constants into
instruction immediates before entering the vertex loop. That keeps the hot
loop as immediate multiplies instead of memory loads.
The projector at 0x11e90 walks vertices as 12-byte XYZ triples. Per vertex,
it multiplies X/Y/Z by the patched matrix terms, stores transformed coordinates,
projects by depth, and packs screen position:
mov eax,[esi] ; x
imul ebx,eax,patched_m00
imul ecx,eax,patched_m01
imul ebp,eax,patched_m02
mov eax,[esi+4] ; y
imul edx,eax,patched_m10
add ebx,edx
imul edx,eax,patched_m11
add ecx,edx
imul edx,eax,patched_m12
add ebp,edx
mov eax,[esi+8] ; z
...
idiv ebp ; perspective divide
...
mov [edi],eax ; packed projected coordinate
The face collector at 0x12043 performs a backface/cross-product style test
from three projected points. It splits faces into two queues based on a parity
bit from depth:
if face_is_visible:
if depth_bit_is_clear:
append to queue A
else:
append to queue B
It then does a bitwise depth sort. The loop starts with ebp=2, partitions by
that bit, doubles the mask each pass, and repeats until the 15-bit sort range
has been consumed:
test ebp,[face+4]
jnz keep_in_front_queue
...
shl ebp,1
dec word [0x10110]
jnz sort_next_bit
That is a compact radix-style sort, appropriate for a 64K intro because it avoids a general comparison sort and keeps face records as 8-byte pointer/depth pairs.
The final raster path starts at 0x12530. It builds edge records from sorted
face vertices, clips against screen limits, and then uses span tables rooted
around 0x100e0..0x100f4. The code is heavily table-driven; the important
point is that the vector engine is not a single triangle filler bolted onto
the intro. It has record parsing, transform patching, visibility splitting,
depth sorting, clipping, and span emission as separate stages.
Waver And Greets Writer
The greets string block starts at unpacked EXE+0x1d7dd:
GREETS
A-MEN
CAPACALA
CHAOS
COMA
EMF
FUTURE CREW
JESKOLA!
MIUMAU
ORANGE
PRIME
SYMPTOM
VIRTUAL VISIONS
The text renderer at 0x1d86d reads the current string pointer from
ds:[0x1c8b8], measures the string with the font-width table at 0x20360,
then renders glyphs from 0x20385.
The glyph loop is direct and old-school:
char_loop:
ch = *esi++
glyph = 0x20385 + (ch - 'A') * 0x28
rows = 0x14
row_loop:
ax = word [glyph]
glyph += 2
xchg al,ah
dx = ax
ecx = 0x0f
bit_loop:
ax = dx
shr ax,cl
test al,1
jz skip
al = [0x1c8bc] ; fade/color
if [edi] < al:
[edi] = al
skip:
dec edi ; horizontal direction is reversed
dec ecx
jns bit_loop
sub edi,0x90 ; move to previous scanline position
dec rows
jnz row_loop
add edi,0x0c80 ; next glyph baseline
The if [edi] < al max-write is the important detail. The greets writer
does not simply stamp opaque font pixels. It raises the destination brightness,
which lets the text sit inside the waver/fire buffer without erasing hotter
pixels.
0x1d911 advances the fade and source pointer. It counts from 0 to 0x1f;
after 0x20 steps it skips over the current word and starts the next one. The
surrounding timeline routine 0x1d959 gates the greets against frame counters
and controls when the palette and page state swap.
Waver Page And Planar Copy Loop
The display-side loop at 0x1e102 shows how the waver buffer is copied into a
planar display. It selects a plane, copies every fourth byte from a chunky-ish
source into contiguous VGA dwords, then rotates to the next plane:
xor esi,esi
mov edi,[0x1c86c]
mov ah,0x11
load ES = VGA selector
load DS = work-buffer selector
plane_loop:
push eax
push edi
push esi
call 0x1df14 ; set sequencer map mask from AH
mov ecx,0x0fa0 ; 4000 dwords
copy_loop:
mov ah,[esi+0x0c]
mov al,[esi+0x08]
shl eax,16
mov ah,[esi+0x04]
mov al,[esi]
stosd ; four separated source bytes become one plane dword
add esi,0x10
dec ecx
jnz copy_loop
pop esi
pop edi
pop eax
inc esi
shl ah,1
jae plane_loop
Each plane pass starts at a different byte phase of the source buffer. This is a typical Mode X chunky-to-planar copy: the effect code can think in a more linear source layout, while the copy loop fans bytes into VGA planes.
End Scroller
The end-scroller starts at 0x1e4ff. It writes directly to VGA CRTC ports and
calibrates its wait loop against vertical retrace:
mov dx,0x03d4
mov ax,0x0009
out dx,ax
mov dx,0x03da
wait_vblank:
in al,dx
test al,0x08
jz wait_vblank
wait_end:
in al,dx
test al,0x08
jnz wait_end
xor ecx,ecx
delay_probe:
inc ecx
cmp ecx,[0x1d3b0]
...
The measured delay is filtered:
lea ecx,[ecx+ecx*2]
shr ecx,1
mov [0x1d3b0],ecx
That gives the scroller a machine-relative wait budget without requiring a large timing system.
The string centerer at 0x1e597 scans the current $-terminated line. Spaces
subtract 8 pixels from the center offset; letters use the width table at
0x20360:
edi = 0x140
for each char:
if char == ' ':
edi -= 8
else:
edi -= width[char - 'A'] >> 1
[0x1d3ac] = edi
The renderer at 0x1e5cb clears a narrow line band, then draws each glyph.
The glyph writer at 0x1e650 is the core unaligned bitblit:
; EDI is a bit-addressed destination.
xor ecx,ecx
shr edi,1
rcr cl,1
shr edi,1
rcr cl,1
shr edi,1
rcr cl,1
shr cl,5 ; CL = bit shift inside destination word
mov ch,8
sub ch,cl
mov bx,0x00ff
shr bx,cl ; low-word mask
mov bh,0xff
add edi,0xa0000
sub edi,[0x18]
lodsw
ror ax,cl
mov dx,ax
and ax,bx
or [edi],ax
if cl != 0:
not bx
and dx,bx
or [edi+2],dx
This is more careful than a byte-aligned font blitter. The end text scrolls at
sub-byte horizontal positions, so a glyph row can straddle two destination
words. ror ax,cl aligns the font row, the mask protects existing bits, and
the carry-over part is ORed into [edi+2] when needed.
The scroller advances by 0x280 bytes per rendered line and wraps at
0x4b000:
eax = [0x1d3a8] + 0x280
if eax >= 0x4b000:
eax -= 0x4b000
[0x1d3a8] = eax
0x1e6d1 then writes the CRTC start address around the updated buffer offset,
which gives the end screen its smooth rolling motion.
Embedded Music State
The unpacked image contains an SCRM signature at unpacked EXE+0x4ccc.
Treating the 44 bytes before it as an S3M-style header gives:
orders: 78
instruments: 14
patterns: 42
global vol: 64
initial speed: 5
initial tempo: 204
The order list begins:
00 01 fe 02 03 04 05 fe 06 06 07 07 08 08 09 09
0a 0b fe 0c 0e 0d 0e 0f 11 12 14 0f 10 12 13 15
This should not be treated as a clean standalone .s3m carve. The pattern
parapointers resolve inside the executable image, but the sample pointer fields
look like runtime/player pointers after relocation or unpacking rather than
simple file-relative offsets. The safe conclusion from static evidence is:
Drift embeds an S3M/SCRM-style module/player state, the top-level code calls a
music service through 0x34e4, and the timer IRQ drives that service once per
70 Hz tick when audio is enabled.
What The Intro Is Doing Overall
Drift's structure is tighter than it first looks:
- WWPACK compresses a DOS extender image into a 65 KB MZ file.
- The real-mode loader checks CPU, memory, A20, DPMI/VCPI, then enters a Tran-style PMODE environment.
- The protected-mode runtime provides a real-mode interrupt bridge at
int 33hand selectors for VGA/work buffers. - A PIT IRQ at roughly 70 Hz drives music and per-part callbacks.
- The foreground script selects sound, initializes mode 13h/tweaked VGA, and calls six effect phases.
- Shared loops handle palette interpolation, vertical retrace waits, Mode X plane selection, page start changes, chunky-to-planar copies, and 3D object drawing.
- The intro ends with a custom bit-addressed end scroller rather than a generic text routine.
The most important inner-loop pattern is data packing. Palette values are interpolated as raw bytes; fire pixels are processed four at a time in a dword; Mode X output repacks every fourth byte into planar dwords; vector constants are patched into immediate operands; and the end scroller treats text as bit-addressed words so it can scroll smoothly without a large framebuffer format conversion.
That combination is what makes the intro feel bigger than its archive size: the code spends bytes on reusable data transforms and tiny runtime services, then lets palette, page, and plane tricks multiply the visual output.