Analysis model: gpt-5.5 xhigh
Bill G Force by Complex - Technical Dissection
Scope
This is a static technical dissection of Bill G Force by Complex, released
for MS-DOS in the Assembly 1995 PC 64K intro competition. The Assembly results
list it as third place, after Wild Light's Drift and COMA's Stickman's World.
Public references:
- Assembly archive: https://archive.assembly.org/1995/pc-64k-intro/bill-g-force-by-complex
- Scene.org archive: https://archive.scene.org/pub/parties/1995/assembly95/in64/clx_bgfr.zip
- Assembly 1995 results: https://archive.scene.org/pub/parties/1995/assembly95/info/asm95res.txt
This is not a source-level reconstruction. It is a binary analysis of the public archive, the RNC-packed MZ executable, the RNC-expanded load image, the manual sound-card setup, the embedded S3M/player path, and the VGA/vector inner loops that can be recovered cleanly from the decompressed image.
Offset notation:
original EXE+0x...means a file offset in the packedCLX_BGFR.EXE.expanded image+0x...means a file offset in the RNC-expanded 393,446 byte load image extracted from the RNC block.- Runtime segment names such as
2b83:0000are real-mode segment addresses used by the code. For the recovered image, the corresponding flat offset issegment * 16 + offset. - When I say "static pass", I mean the code was disassembled and correlated with data offsets, calls, and tables. I did not recover symbolic source.
Position In Assembly 1995
The Assembly 1995 result file lists the PC 64K intro competition as:
1. Wild Light: Drift
2. COMA: Stickman's World
3. Complex: Bill G Force
That context matters because all three entries solve similar practical
problems in different ways: a packed 64K executable, sound-card setup, a module
player, a timer-driven frame loop, and a VGA renderer. Bill G Force is the
most obviously "engine-like" of the three: instead of a small special-purpose
stick renderer or a PMODE intro framework, it has a compact real-mode 386
scene system with object records, transformed vertex buffers, face sorting,
textured/shaded spans, palette fades, and a planar VGA final copy.
Examined Files
Archive contents:
clx_bgfr.zip 65,815 bytes
CLX_BGFR.EXE 65,830 bytes
CLX_BGFR.PIF 967 bytes
CLX_BGFR.TXT 38 bytes
clx_bgfr.diz 144 bytes
CLX_BGFR.TXT contains only:
clx_bgfr.exe = Bill G Force by Complex
The separate .diz file in the scene.org directory says the copy was
virus-checked and spread by Gloom/Spin at The Party 1995. There is no detailed
NFO in the archive, so the binary itself is the useful source for credits and
structure. The intro's own title strings include:
COMPLEX
BILL G-FORCE
J MAGIC
JUGI
REWARD
Important hashes:
916e45b561b6524f89f2c8cebd63e183d4f207fddf804db2f436090abab4a840 clx_bgfr.zip
1413ad51a37721842ebb22191d3f2fbb1540a419f539ec6d815044306af00c7c CLX_BGFR.EXE
e04681f36dd2287c7e8090f9b2eb94ed892ba34a3e82d6f4b323f89e4a3556ad CLX_BGFR.PIF
918daaa831224af38a4e1e25eb223044328c8f27693817275292fe55ab780962 CLX_BGFR.TXT
58a9d2757bc908a7903ba9f9c59edafe64673691ba015d3dd74964a68282cb25 clx_bgfr.diz
1c4bc23735dae89d2618dc1877f494ccfce2fb103e8388950a56d99044b9c7ea RNC-expanded load image
Packed EXE And RNC Block
The public executable is a real-mode MZ file:
file size: 65,830 bytes
MZ header size: 32 bytes
relocation count: 0
initial CS:IP: 0fdb:000c
initial SS:SP: 6010:0556
entry file offset: original EXE+0xfddc
The compressed payload starts immediately after the 32-byte MZ header:
original EXE+0x20: 52 4e 43 01 ...
The RNC header decodes as:
method: 1
unpacked size: 393,446 bytes (0x600e6)
packed size: 64,923 bytes (0xfd9b)
unpacked CRC: 0x0bca
packed CRC: 0xed75
leeway: 0
chunks: 33
The original entry at original EXE+0xfddc is the RNC depacker/stager. It
copies itself to a safe location, builds temporary decode tables on the stack,
decompresses the RNC block, applies relocation-style fixups, restores SS:SP,
and then jumps through the recovered entry pointer. The static analysis below
uses the unpacked RNC output directly, not the packed depacker body.
The expanded image is not an MZ file. It is a raw real-mode load image. The first bytes are setup-menu data and IRQ lookup bytes:
00 02 03 05 07 0b 0f ...
"Select output device..."
That also explains why generic file-identification tools are not meaningful on the decompressed block; they see a raw memory image, not an executable format.
Runtime Capture
A DOSBox-X 2026.01.02 capture on 19 June 2026 used the public CLX_BGFR.EXE
from the archive above. For this visual pass, the setup menu was answered with
4 / No Sound. That is not the ideal way to hear the intro, but it is a
valid visual route for this program: the no-sound timer path described below
increments a local counter in place of the S3M callback, so the scripted show
continues without requiring a working Sound Blaster or GUS setup in the
headless emulator. Timing zero is the start of the capture stream, including
the DOSBox-X shell and sound-device prompt. The run was stopped by the external
capture timeout after 158.3 seconds; the selected frames are from the stable
visual portion before the black tail.
The sequence GIF below is assembled directly from the eight captured runtime frames. It compresses the visible arc of the intro into one motion preview: terrain-backed Complex/title/credit cards, the persistent upper-right badge, the colored light-cluster pass, the yellow grid composite, and the late shaded-object scene.

At 00:15.000, the title script has reached the first self-identifying card.
The blue, scanlined terrain is already moving behind the spaced COMPLEX
letters, establishing the intro's main dark landscape surface before the
object scenes take over.

At 00:21.000, the same terrain pass carries the production title. This is a
good anchor for the hard-coded timeline discussed later: the title is not a
separate static screen, but a text phase laid over the same moving background.

At 00:30.000, the credit text has moved on to J MAGIC. Small yellow points
are now visible across the surface, so the frame ties the intro text and the
landscape/light-field layer together.

At 00:42.000, the gold C badge has appeared in the upper right while the
background continues to scroll. This badge remains a stable overlay through
the next effect, making the page-flip/composite stage easier to recognize in
the later code.

By 01:12.000, the intro is in the blurred light-cluster phase. The scene is
still built on the dark terrain base, but the renderer is now adding soft,
colored blobs and point-like highlights instead of just title text.

At 01:33.000, the light clusters sit over a more explicit yellow grid and
line pattern. This is the clearest still for the compositing path: background,
line/point layer, blur-like colored forms, and the upper-right badge all share
one final VGA copy.

At 02:02.000, the intro has shifted into the later shaded-object scene. The
palette and background are warmer and more purple, and the brown object is now
large enough to connect the visible result to the transformed-vertex, face
sorting, and span-rendering sections below.

At 02:30.000, the object pass is closer and more legible. This late frame is
the visual reason for the renderer depth in the static analysis: the intro is
not only a title/landscape scroller, but a compact object engine with shaded
forms, page composition, and packed planar output.

Runtime Memory Map
The intro is still a real-mode DOS program, but it uses 386 registers and segment registers aggressively. The important recovered runtime segments are:
| Segment | Flat offset | Role |
|---|---|---|
092c |
0x092c0 |
copied/generated texture or image work source |
1def |
0x1def0 |
embedded S3M module |
2876 |
0x28760 |
font/glyph data for title text |
2b83 |
0x2b830 |
object/mesh data used by the initial scene |
2e72 |
0x2e720 |
small source table/texture data used by the main renderer |
33ae |
0x33ae0 |
off-screen or staging buffer for 32x32 block compositing |
43ae |
0x43ae0 |
64x64 lookup table generated at startup |
47ae |
0x47ae0 |
main work buffer / transformed vertex and framebuffer state |
5ce6 |
0x5ce60 |
S3M/sound driver segment |
The code resizes its DOS memory block to 0x6400 paragraphs, roughly 400 KB.
Its failure text says:
Memory allocation failure, ~600k required
That is not an exact paragraph count. It is the user-facing requirement for the whole real-mode load image and DOS environment.
Manual Sound Setup
The setup routine starts at expanded image+0x0208. It prints three
$-terminated DOS strings and reads a single digit for each choice through
the helper at 0x01d6.
Device choices:
| Key | Meaning | Stored value |
|---|---|---|
1 |
Sound Blaster mono | cs:3c6e = 0x40 |
2 |
Sound Blaster Pro stereo | cs:3c6e = 0xc2 |
3 |
Gravis UltraSound | cs:3c6e = 0x01 |
4 |
No Sound | cs:3c6e = 0xff |
Port choices map directly to the visible menu:
expanded image+0x0239:
call 0x01d6
and ax,000fh
shl ax,4
add ax,0200h
mov cs:[3c6fh],ax ; 210h, 220h, ... 260h
IRQ choices use the byte table at the start of the expanded image:
index: 1 2 3 4 5 6
table byte: 2 3 5 7 11 15
The setup helper at 0x01d6 uses DOS console input (int 21h, AH=07h) and
rejects values outside 1..6. It echoes the accepted digit with AH=02h,
prints a backspace, returns the normalized low nibble, and treats Ctrl-C or
ESC as immediate DOS termination.
The no-sound path is literal code patching:
expanded image+0x3cfc:
cmp byte cs:[3c6eh],0ffh
jne sound_enabled
mov ax,5ce6h
mov es,ax
mov byte es:[1a43h],0cbh ; replace driver entry with retf
After this patch, any later far call to 5ce6:1a43 returns immediately.
Embedded S3M And Player Dispatcher
The embedded module starts at runtime 1def:0000, flat
expanded image+0x1def0. The SCRM signature is at 0x1df1c, exactly 44
bytes after the S3M header start.
Recovered S3M header:
orders: 36
instruments: 19
patterns: 21
tracker: 0x1300
format: 0x0002
global vol: 64
initial speed: 6
initial tempo: 125
master vol: 176
channels: 0, 9, 10, 3, 4, 13, 14, 7, then disabled channels
The instruments are unnamed. Nine are active sample instruments in the static header pass; the rest are empty slots. Sample lengths include 1962, 3092, 2418, 604, three small 26-to-28 byte looped waveforms, a 7446 byte sample, three 200 byte samples, and a final 3874 byte sample.
The player is called through 5ce6:1a43. In flat expanded-image coordinates
that far entry lands at 0x5e8a3, immediately reaches a compact jump-table
dispatcher, and branches by command number. The recovered command table at
driver offset 0x1546 is:
| Command | Driver offset | Flat offset | Observed role |
|---|---|---|---|
| 0 | 0x1a5e |
0x5e8be |
no-op/default |
| 1 | 0x1a5f |
0x5e8bf |
initialize selected output device |
| 2 | 0x1c5e |
0x5eabe |
start playback/timer path |
| 3 | 0x1c7a |
0x5eada |
stop/restore at exit |
| 4 | 0x1ce3 |
0x5eb43 |
per-frame/player update |
| 5 | 0x1a5e |
0x5e8be |
no-op/default |
| 6 | 0x1a5e |
0x5e8be |
no-op/default in this table |
| 7 | 0x1b4b |
0x5e9ab |
bind/parse S3M module |
| 8 | 0x1d5b |
0x5ebbb |
auxiliary driver command |
| 9 | 0x1dc7 |
0x5ec27 |
auxiliary driver command |
| 10 | 0x1e1f |
0x5ec7f |
auxiliary driver command |
| 11+ | 0x22d3 or 0x22e4 |
0x5f133+ |
default/extended cases |
The main script uses these player calls:
AX=0001h, AH=device, BH=irq, DX=port ; initialize card
AX=0007h, DX=1defh ; bind S3M at 1def:0000
AX=0006h ; harmless/default in this build
AX=0002h ; start playback
AX=0004h ; update while rendering
AX=0003h ; stop at exit
This is the same general player-dispatcher family as some other 1995 PC intros in this series, but the surrounding engine is distinct.
VGA Setup
The VGA setup routine at expanded image+0x3f48 starts in normal Mode 13h and
then tweaks it into an unchained planar 320x200-like mode:
mov ax,0013h
int 10h
; clear DAC entries
mov dx,03c8h
xor al,al
out dx,al
inc dl
mov cx,0300h
zero_dac:
out dx,al
loop zero_dac
; unchain / odd-even changes
mov dx,03c4h
mov ax,0604h
out dx,ax
mov dl,0d4h
mov ax,0014h
out dx,ax
mov ax,0e317h
out dx,ax
mov ax,0009h
out dx,ax
mov dl,0c4h
mov ax,0f02h
out dx,ax
Then it clears VGA memory and the main work segment:
ES = a000h
ECX = 0x4000 dwords
rep stosd ; 64 KB
ES = 47aeh
ECX = 0x3e58 dwords
rep stosd ; work buffer clear
Finally it waits for vertical retrace and uploads 64 RGB palette entries
starting at DAC index 0xc0:
mov si,6ab7h
mov dx,03c8h
mov al,0c0h
out dx,al
inc dl
mov cx,00c0h
rep outsb ; 64 * RGB
Most rendered pixels in the span code are 0xc0 + shade, so this 64-color
range is the active shaded palette.
Timer IRQ And Frame Scheduler
The timer install path is at expanded image+0x0f49. It saves the old INT 8
vector from 0000:0020, writes the new vector to cs:0ef5, calibrates the
PIT divisor, and starts using a variable-rate IRQ tick.
The IRQ body at 0x0ef5:
cli
push ax
mov al,20h
out 20h,al ; EOI early
push dx
inc word cs:[0ef3h] ; intro tick counter
mov bx,cs:[2ebdh] ; CRTC display-start offset
mov dx,03d4h
out dx,0cXXh ; CRTC start high
out dx,0dXXh ; CRTC start low
wait_for_retrace
program PIT divisor from cs:[0eddh]
inc word cs:[2ebbh] ; pending frame/update count
call 0x2f24 ; palette/music/no-sound callback
add cs:[0edfh],cs:[0eddh]
if carry: jump old INT 8
else: iret
The carry-based old-IRQ chain is a classic fixed-point trick. The custom timer can run at the rate the intro wants, while the BIOS clock is still called at the proper average rate.
The restore routine at 0x0fb6 reinstalls the old INT 8 vector and calls the
PIT reset helper.
There are two high-level wait helpers:
0x0e3b: waits against the intro tickcs:0ef3.0x0e6f: waits against the music/player tick5ce6:0a9c.
Both repeatedly call the render/update routine 0x0e0a, poll the keyboard via
int 16h AH=01h, and jump to the cleanup path if a key is pressed.
Main Script
The central startup/body script sits around expanded image+0x3cb0. The
nearby bytes at 0x3c75 are a call/pop printer for the memory-failure string;
the successful path continues through 0x3cb0.
The startup sequence is:
mov ax,es
mov cs:[3c73h],ax
mov ah,4ah
mov bx,6400h
int 21h ; resize DOS memory block
DS = 092ch
ES = 47aeh
CX = 1194h
rep movsd ; seed work buffer
DS = 47afh
call 0x409c ; copy 256 RGB triples into 4-byte palette map
DS = 47dfh
call 0x40e2 ; prefilter texture/image block
FS = 2b83h
call 0x071c ; build face and vertex normals
call 0x40be ; recurrence table
call 0x4053 ; clamp/ramp table
call 0x3f14 ; projection/table setup
call 0x3fb7 ; small randomized/object table setup
call 0x4068 ; 64x64 shade lookup
call 0x0208 ; sound setup menu
Then it initializes the driver, switches VGA, installs the timer, starts the music, and begins a hand-scripted timeline. The title portion is explicit:
wait music tick 0x0080
draw string at 0x15cd ; COMPLEX
enable text plane copy
wait 0x00c0
draw string at 0x15e4 ; BILL G-FORCE
wait 0x0100
clear/draw blank string
wait 0x0140
draw string at 0x15f8 ; J MAGIC
wait 0x0180
draw string at 0x1619 ; REWARD
wait 0x01c0
draw string at 0x1609 ; JUGI
The later script changes camera/object parameters, swaps palette/source
tables, patches one internal routine byte to ret for a section, then restores
or changes it again. The important point is that the main script is not a
passive loop over a file format. It is a compact hard-coded timeline that
mutates engine globals and lets the common frame update draw the current state.
At exit it fades the DAC to black, restores the timer, calls player command 3,
returns to BIOS text mode 3, and terminates through DOS int 21h AH=4Ch.
Render Update Loop
The recurring render update is the routine at expanded image+0x0e0a:
call 0x0c74 ; build visible face/object list
call 0x0cb8 ; sort/reorder list
mov ax,0004h
call 5ce6:1a43 ; player update
call 0x3bd9 ; patchable stage, sometimes turned into ret
call 0x347f ; table/image generator
mov ax,0004h
call 5ce6:1a43
call 0x0a50 ; draw triangles from object list
call 0x3280 ; postprocess/copy to VGA
mov ax,0004h
call 5ce6:1a43
call 0x2fb7 ; advance globals for pending frames
That is a useful mental model for the intro:
- Update face/object lists.
- Service the music driver.
- Generate or transform source imagery.
- Rasterize visible geometry.
- Composite/copy work buffers to planar VGA.
- Advance camera, palette, and timeline globals.
Runtime-To-Code Concordance
The captured GIF and eight timestamped frames are useful because they cover the same visible states named by the hard-coded script and recurring update loop. The mapping is not just visual guesswork: the text timings, no-sound fallback, object renderer, postprocess, and VGA copy all have concrete offsets in the RNC-expanded image.
00:15.000 COMPLEX title over blue terrain
main script waits for music tick 0x0080, draws the string at
0x15cd, enables the text-plane copy, and lets the recurring update
at 0x0e0a keep generating the moving terrain/source field.
00:21.000 BILL G-FORCE title on the same moving terrain
the next script gate waits for 0x00c0 and draws the string at
0x15e4. The background persistence shows this is a text overlay
phase, not a separate still screen.
00:30.000 J MAGIC credit with yellow points on the surface
the script reaches the 0x0140 gate and draws 0x15f8. The generator
at 0x347f and block/composite path at 0x3014/0x3280 keep evolving
the field underneath the credit.
00:42.000 upper-right Complex badge over continuing terrain
this is where the page composition is visible: the work buffer,
optional projected point/object pass, text-plane copy at 0x3243,
and CRTC page flip via cs:2ebd all combine into one display.
01:12.000 blurred colored light clusters
the projected point/block stage is now dominant. The 32x32
compositor at 0x3014 blends source channels through the clamp/ramp
table at cs:91b2 and the generated lookup tables instead of drawing
raw unblended sprites.
01:33.000 yellow grid / line pass under the light clusters
this frame exposes the layered postprocess: generated source image
at 0x347f, byte-pair mixer in 0x3280, projected block compositor,
and final two-plane VGA packing all have to agree on the same
160-wide logical layout.
02:02.000 shaded object scene enters
the face/object path now explains the visible result: object records
collected at 0x0c74, vertices transformed/projected at 0x0280 and
0x0d40, faces culled/sorted at 0x0aa6/0x0cb8, and triangles sent
through 0x0fe1 and the span filler.
02:30.000 close shaded-object pass
the object is close enough to make the rasterizer important. The
hot span loop at 0x10d6 samples the selected FS texture/shade table,
adds palette base 0xc0, writes into the work surface, then 0x3280
repacks that surface into unchained VGA planes.
Timing also survives the no-sound capture choice. The setup menu patch at
0x3cfc replaces the sound-driver entry with retf, but the timer callback at
0x2f24 still increments the fallback player tick at 5ce6:0a9c. That is why
the 0x0e6f music-tick waits in the main script continue to advance during the
DOSBox-X capture used for the published frames.
The shared frame backbone is:
0x0ef5 timer IRQ increments intro ticks and pending frame count
0x2f24 palette fade / music-or-no-sound tick callback
0x0e0a recurring render update
0x347f generated source/terrain-like image field
0x0c74 visible object/face list collector
0x0a50 triangle walker
0x10d6 table-textured span filler
0x3014 32x32 blended block compositor
0x3280 byte-pair postprocess and planar VGA copy
0x3243 optional title/text plane copy
So the article's runtime GIF is not merely illustrative. It exercises the same pipeline described by the disassembly: a music-tick-gated script mutates text, palette, camera, object, and generator state, while one recurring render/update path composes terrain, point blobs, shaded geometry, text, and the final unchained-VGA page.
Vertex Transform And Projection
The core vertex transform routine is expanded image+0x0280. It receives a
vertex index in SI, converts it to a six-byte vertex record, optionally
applies an auxiliary offset table from fs:8, and reads signed 16-bit
coordinates:
shl si,1
lea si,[esi+esi*2] ; index * 6
if fs:[8] != 0:
si += fs:[8]
read auxiliary x/y/z
multiply by 2x3 matrix row pair
preserve packed result in DX
si += fs:[4] ; vertex table base
x = sign16 fs:[si+0]
y = sign16 fs:[si+2]
z = sign16 fs:[si+4]
The main transform then adds object/world translation:
z += cs:[0a22h]
y += cs:[0a1eh]
x += cs:[0a1ah]
It multiplies the translated coordinate by a 3x3 matrix stored at
cs:0498..04b8:
out_x = x*m00 + y*m01 + z*m02 -> cs:[026c]
out_y = x*m10 + y*m11 + z*m12 -> cs:[0270]
out_z = x*m20 + y*m21 + z*m22 -> cs:[0274]
The projection loop at 0x0d40 calls this transform for every vertex in the
current object. It stores three per-vertex streams in the GS=576e buffer:
gs:[si+12c0h] = packed auxiliary/projected data
gs:[si+2260h] = depth-ish value: (out_z >> 20) + 4000h
gs:[si+1a92h] = screen x
gs:[si+1a90h] = screen y
The perspective divide is explicit:
depth = out_z - (cs:[0471] << 8)
screen_x = ((out_x * focal) / depth) / 2 + 0x50
screen_y = ((out_y * focal) / depth) / 2 + 0x42
The earlier projection loop at 0x03a0 is a close sibling using fixed focal
globals at cs:0477 and cs:047b; the later 0x0d40 path uses cs:0a30
for both axes. The constants 0x50 and 0x42 center the visible 160x134-ish
rendering window inside the tweaked VGA layout.
Face Normal And Vertex Normal Builder
The normal builder starts at expanded image+0x071c. It sets GS=47ae and
uses FS as the object/mesh segment.
For each face:
face_count = fs:[2]
face_list = fs:[6]
vertex_base = fs:[4]
read three face vertex indices from fs:[si+2], [si+4], [si+6]
index = (raw_index >> 2) * 6 + vertex_base
load x/y/z from vertex records
sar each coordinate by 6
It forms two edge vectors:
e1 = v1 - v0 -> cs:0970,0978,0980
e2 = v2 - v0 -> cs:0974,097c,0984
Then the cross product:
nx = e1.z * e2.y - e1.y * e2.z -> cs:099a
ny = e1.x * e2.z - e1.z * e2.x -> cs:099c
nz = e1.y * e2.x - e1.x * e2.y -> cs:099e
The normalization helper at 0x06ac squares the components, calls a local
integer square-root helper at 0x067f, guards zero length with 0x07d0, and
rescales the vector to length 0x07d0:
len = sqrt(nx*nx + ny*ny + nz*nz)
if len == 0:
len = 0x07d0
nx = nx * 0x07d0 / len
ny = ny * 0x07d0 / len
nz = nz * 0x07d0 / len
The per-face normal is stored as three 16-bit words in the GS=47ae buffer.
After the face-normal pass, the routine computes vertex normals. For every
vertex it scans all faces, tests whether the current vertex index occurs in
the face's three index slots, accumulates the matching face normals, normalizes
the sum through the same helper, multiplies each component by 11, and writes
the result back into the object segment's vertex-normal table at fs:[8].
That second pass is expensive but compact: no adjacency lists are stored. For the small meshes in a 64K intro, scanning faces is cheaper in code size than shipping another table.
Object List, Culling, And Sorting
The object/face collector at expanded image+0x0c74 walks object records
starting at cs:09a8. Each record is 0x26 bytes. It rejects records with
null or sentinel fields, then calls 0x0bb7.
The per-record routine at 0x0bb7:
FS = object segment from record[0]
load camera/object translations from record fields
copy them into cs:[0469..0471] and cs:[0a1a..0a22]
copy winding flag into cs:[0a46]
copy shade/texture phase into cs:[0bb5]
if fs:[2] == 0: skip
call 0x04c2
call 0x0d40 ; transform/project vertices
if record type != 2:
call 0x0aa6 ; collect visible faces
The face collector at 0x0aa6 performs a screen-space backface test. It
computes:
cross =
(x2 - x0) * (y1 - y0)
- (x1 - x0) * (y2 - y0)
Then it compares the sign against cs:0a46, so the winding can be inverted by
record data. Accepted faces are appended to the GS=576e list. For each face
it stores:
vertex0 projected-buffer offset -> gs:[bp+2a30]
vertex1 projected-buffer offset -> gs:[bp+2ee0]
vertex2 projected-buffer offset plus shade low bits -> gs:[bp+3390]
sort key = average depth in high word plus list index in low word -> gs:[si]
The sorter at 0x0cb8 is compact and unusual. It repeatedly partitions the
list by a single bit in the 32-bit sort key, starting with EDX=0x00200000 and
left-shifting until carry. For each bit, entries with the bit clear are written
forward and entries with the bit set are written backward. Then the temporary
ordering is copied back to the live list.
That is essentially an in-place most-significant-bit radix partition for the visible face list. It avoids a compare/swap sort and keeps code size low.
The triangle walker at 0x0a50 then iterates the sorted list until the
0xffff sentinel. For each face it:
read vertex offsets from gs:[2a30], [2ee0], [3390]
extract low two shade/texture bits from vertex2 record
select texture/shade table segment from cs:[09a0 + lowbits*2]
mask vertex offsets to dword alignment
call 0x0fe1 ; triangle setup/rasterizer
Triangle Setup
The triangle entry at expanded image+0x0fe1 receives three vertex-buffer
offsets in SI, DI, and BP. It reads the projected y fields from
GS:[vertex+1a90], does a coarse off-screen test, sorts the vertices by y,
rejects triangles outside the vertical window, and stores sorted y values into
cs:1080, 1084, and 1088.
It then reads the packed x/texture-ish values from GS:[vertex+12c0] into
cs:10a6, 10aa, and 10ae, and jumps into 0x1290.
The setup at 0x1290 computes:
dy_top_mid = y1 - y0 -> cs:10a0
dy_top_bot = y2 - y0 -> cs:10a2
dy_mid_bot = y2 - y1 -> cs:10a4
edge_slope_top_mid = (x1 - x0) / dy_top_mid -> cs:108c
edge_slope_top_bot = (x2 - x0) / dy_top_bot -> cs:1090
edge_slope_mid_bot = (x2 - x1) / dy_mid_bot -> cs:1094
It also computes per-scanline texture coordinate deltas at cs:115c,
cs:115e, and cs:1127/1129, clips the top and bottom y to the visible
range 1..0x86, converts y into byte offsets using a 160-byte stride, and
calls the span filler once for the top half and once for the bottom half.
This is a conventional sorted triangle rasterizer, but the implementation is heavily packed around self-stored edge deltas and 16.16 fixed point.
Span Filler Inner Loop
The hot span routine begins at expanded image+0x10d6. It receives a line
count in DX, adds 0x00a00000 into the edge accumulators, and chooses
between a fast unclipped path and a clipped path using cs:10c0.
Fast path core, at 0x112e..0x117d:
line_loop:
push bp
mov di,bp
sub bp,dx ; span length encoded through BP/DX
jns no_pixels
sub di,bp
pixel_loop:
mov bl,ch ; high byte of texture accumulator
shld ebx,ecx,9 ; combine texture bits into table index
mov bl,[bx] ; DS is FS texture/light table
add bl,0c0h ; shaded palette range
add ecx,esi ; texture accumulator += step
mov es:[bp+di],bl
inc bp
jne pixel_loop
no_pixels:
pop bp
add cs:[10c8],texture_line_delta
add/adc edge accumulators
dec cs:[0fd0]
mov ecx,cs:[10c8]
jne line_loop
The key operation is this:
mov bl,ch
shld ebx,ecx,9
mov bl,[bx]
add bl,0c0h
mov es:[...],bl
It builds a compact lookup index from the high bits of a 32-bit texture
accumulator, reads a byte from the selected FS table, converts it into the
active 64-color palette range by adding 0xc0, and writes one pixel. There is
no per-pixel divide or multiply in the raster hot loop. All expensive geometry
math has already been paid in setup.
The clipped path at 0x11a0..0x1288 does the same lookup/write but intersects
each span with 160-byte screen-line boundaries. Its pixel core is:
mov bl,ch
shld ebx,ecx,9
add ecx,ebp
mov ah,fs:[bx]
inc si
add ah,0c0h
mov es:[si-1],ah
dec al
jne pixel_loop
The clipped path is slower, but it preserves the same one lookup and one store per pixel once inside the visible interval.
Texture And Shade Tables
Several startup helpers build the tables used by the rasterizer and compositor.
0x4053 builds a clamp/ramp table at cs:91b2:
for values 0..0x3e:
table[i] = i
for remaining 0xc1 bytes:
table[i] = 0x3f
That makes later blend lookups saturate at 63.
0x4068 builds a 64x64 lookup table in segment 43ae:
for x in 0..63:
for y in 0..63:
v = (x * 0x23 + y * 0x1d) >> 6;
if (v > 0x3f) v = 0x3f;
table[x * 0x100 + y] = v;
The 256-byte row spacing (x * 0x100) is deliberate. It lets the code use one
byte as a row component and one byte as a column component without packing or
masking them into a dense 4096-byte table.
0x409c copies 256 RGB triples into a four-byte-per-entry table at
cs:8db2. Each source entry becomes:
cs:8db2 + index*4 + 0 = red-ish byte
cs:8db2 + index*4 + 1 = green-ish byte
cs:8db2 + index*4 + 2 = blue-ish byte
cs:8db2 + index*4 + 3 = unused/padding
The three channels are later used as separate blend-table indices.
0x40e2 prefilters a 128x128-ish byte image. Its first pass looks at adjacent
input bytes. If the high three bits match (0xe0e0 mask), it averages the low
six-bit parts and keeps the common high bits:
if ((a & 0xe0) == (b & 0xe0)) {
out_pair = { a, ((a & 0x3f) + (b & 0x3f)) / 2 | (a & 0xe0) };
} else {
out_pair = { a, a };
}
The second pass performs the same idea vertically using an offset of 0x200.
The result is a smoothed/interleaved source block in segment 092c.
0x40be generates a 0x7fe-dword recurrence table at cs:6b8d:
ebx = previous dword
eax = ebx
imul ebx
shrd eax,edx,0x1d
sub eax,[di-8]
stosd
The exact mathematical identity is not fully named in this pass, but it is a second-order recurrence used as a compact trig/noise-like table. The later image generator samples nearby generated values by masked offsets.
Palette Callback
The timer callback at expanded image+0x2f24 handles palette fades and a
no-sound fallback tick.
When cs:2f35 is nonzero, it adjusts cs:2ec3 toward 0x0000 or 0x4000,
uses helper 0x2f05 to build a 64-byte remap at cs:2ec5, and rewrites the
DAC:
si = 6877h
dx = 03c8h
al = 0
out dx,al
inc dl
cx = 0x240 ; 192 DAC component writes
for each component:
bl = cs:[si] ; source palette ramp index
bl = cs:[2ec5+bl] ; fade/remap
al = cs:[91b2+bl] ; clamp/ramp table
out dx,al
si++
So the fade is not a full RGB interpolation inside the IRQ. The IRQ builds and uses a compact remap/ramp table, then streams the resulting DAC bytes.
If the selected device is No Sound, the same callback increments a local
counter and every few IRQs manually increments the player tick word
5ce6:0a9c. That lets the 0x0e6f music-tick waits progress even though the
player entry has been patched to retf.
The frame advance routine at 0x2fb7 consumes cs:2ebb, the pending frame
count incremented by the timer IRQ. For each pending frame it updates camera
or object globals:
cs:09b8 += 0x008c
cs:09ba += 0x006e
cs:09bc += 0x003c
cs:8dac -= cs:3012
cs:8d99 += 0x8000
clamp cs:2b71 up to 0x3c
That is why the frame loop can tolerate variable numbers of timer events: the render path consumes however many frame ticks are pending.
Title Text Renderer
The title string renderer starts at expanded image+0x162c. It clears a
temporary bitmap at cs:1711, sets FS=2876 as the font segment, and walks a
NUL-terminated string supplied in BX.
Important state:
cs:16d0 = current string pointer
cs:16d2 = x cursor in temp bitmap
cs:1711 = temp bitmap destination
FS:0004 = glyph source stride
FS:0006 = glyph height
cs:16d6 = character width table for ASCII 0x20+
For each printable character:
- Convert ASCII to a font table index by subtracting
0x20. - Look up the glyph width in
cs:16d6. - Sum previous widths to find the glyph source offset, starting from
0x030a. - Copy nonzero glyph bytes into
cs:1711 + x + row*0x140. - Advance the cursor by the glyph width.
The copy loop is sparse:
mov al,fs:[si]
inc si
test al,al
je skip
mov es:[di+1711h],al
skip:
inc di
dec cl
jne glyph_row_loop
So zero bytes in the font are transparent. The text renderer only prepares the
bitmap; the later VGA plane copy at 0x3243 transfers it to display memory
when cs:3240 is enabled.
Text Plane Copy
The routine at expanded image+0x3243 checks cs:3240; if zero, it returns.
When enabled it copies the temporary text bitmap through VGA plane masks:
si = 1711h
dx = 03c4h
out index 2
al = 1
for plane mask 1,2,4,8:
out 03c5h,al
di = 3c00h
for 16 rows:
for 80 bytes:
ah = cs:[si]
if ah != 0:
es:[di] = ah
si += 4
di++
si = original_si + 1
al <<= 1
The si += 4 and then si = original_si + plane pattern deinterleaves a
linear 4-plane temporary bitmap into unchained VGA planes. This is why the text
is rendered into a 0x140-stride buffer: it is already arranged for 320-byte
rows that can be split by plane.
Source Image Generator
The generator at expanded image+0x347f fills a block in segment 2e72 using
the recurrence table at cs:6b85+. It picks two dword values based on
cs:8dac and cs:8dac+0x800, multiplies them into deltas, adds base offsets
from cs:8d99 and cs:8d9d, and then enters a very large unrolled sampler.
The repeated inner pattern is:
mov bl,ch
mov bh,dh
add cx,si
add dx,bp
mov al,[bx]
mov bl,ch
mov bh,dh
mov ah,[bx]
add cx,si
add dx,bp
stosw
This samples a 256x256-style byte table using the high bytes of two fixed-point
coordinates, writes two samples per stosw, and repeats the operation many
times inline. After a forward run it pops the original coordinates and performs
a reverse run with std, subtracting the deltas. The result is a mirrored or
symmetrical generated texture/image block.
It is a classic size/speed compromise: the code spends bytes on unrolling so the per-sample loop has no branch overhead, no multiply, and only byte-indexed table reads.
Block Compositor
The routine at expanded image+0x3014 composites a 32x32 block from
DS=47ae into ES=33ae. It is called from the postprocess path at 0x3367
for projected points or small sprites.
Inputs:
DI = depth/size-ish value, clamped to 0..31 and multiplied by 0x800
CX = screen x, adjusted by -32
DX = screen y, adjusted by -32
cs:307b/307f/3083 = per-channel deltas patched before the call
It first clips the 32x32 block against rough bounds:
if y < -63 or y > 132: return
if x < -63 or x > 159: return
Then it builds three 16-byte lookup ramps at cs:3210, cs:3220, and
cs:3230. These are generated by repeatedly adding the patched channel
deltas. The block draw core reads the existing destination byte from ES,
adds the source channel byte and the channel ramp, and looks up the saturated
blend through cs:91b2:
dl = es:[di] ; existing destination
bl = source_byte + cs:[3210+dl]
al = cs:[91b2 + bx + dx]
bl = source_byte_1 + cs:[3220+dl]
ah = cs:[91b2 + bx + dx]
bl = source_byte_2 + cs:[3230+dl]
dl = cs:[91b2 + bx + dx]
store three blended source bytes
There are two variants:
0x3107draws a full unclipped 64-byte-wide internal span.0x31a7handles horizontally clipped spans, withcs:31aepatched to the visible width.
Even though the caller thinks in 32x32, the internal bytes are three-channel
packed data, so the loop advances SI by 3 per pixel and by larger row
strides (0x120 or 0x1e0) depending on clipping.
Final Planar Copy
After the triangle and block stages, expanded image+0x3280 performs the
postprocess and VGA copy.
The first part mixes a source table at FS=2e72 into the DS=47ae work buffer
using the generated 64x64 table in GS=43ae and the palette-map table
cs:8db2:
for 0x5320 source bytes:
src = fs:[si]
bl = cs:[8db2 + src*4 + 0]
bh = ds:[bp+0]
ds:[bp+0] = gs:[bx]
bl = cs:[8db2 + src*4 + 1]
bh = ds:[bp+1]
ds:[bp+1] = gs:[bx]
bl = cs:[8db2 + src*4 + 2]
bh = ds:[bp+2]
ds:[bp+2] = gs:[bx]
bp += 3
si += 1
This is byte-pair compositing. One byte comes from the new generated/source image and the other from the existing work buffer; together they form a two-byte lookup into the 64x64-ish blend table.
If cs:300f is clear, the routine also renders a projected object/sprite pass
by setting FS=5762, GS=576e, projecting vertices through 0x0d40, and
calling the 32x32 compositor for each point.
The final VGA copy chooses one of two display pages:
ax = cs:[8db0] & 1
ax = ax * 0x07d0 + 0xa000
es = ax
Then it writes work-buffer data to unchained VGA using plane masks:
out 03c4h,0302h ; planes 0 and 1
copy 0x85 rows * 0x14 groups
out 03c4h,0c02h ; planes 2 and 3
copy 0x85 rows * 0x14 groups
The hot copy loop reads 24 bytes of chunky-ish source per group and writes three dwords into VGA memory:
load pieces from [si+0..0x14]
pack them into EAX, EBX, EDX
or EDX,80808080h
mov es:[di+0a0h],edx
mov es:[di],eax
or EBX,40404040h
mov es:[di+4ch],ebx
si += 0x18
di += 4
This is not a simple memcpy. It repacks chunky/interleaved work-buffer bytes
into the two VGA plane groups expected by the tweaked mode. After the copy it
calls the optional text-plane copier and then flips the visible CRTC start
address by storing a new value in cs:2ebd and toggling cs:8db0.
Why This Inner Loop Matters
Bill G Force is visually fancier than its tiny archive suggests because the
engine keeps the expensive work out of the per-pixel loop:
- Object coordinates are transformed once per vertex with 32-bit fixed-point matrix math.
- Faces are culled and sorted into a compact visible list.
- Triangle setup computes all edge and texture deltas before rasterization.
- The span loop only advances fixed-point accumulators, reads one lookup byte, adds the active palette base, and writes one pixel.
- Postprocess and final copy are table-driven byte-pair mixers, not arithmetic blenders.
- The VGA final stage writes planar memory in packed dword groups, not through BIOS or one byte per visible chunky pixel.
The code is therefore not merely "a 3D intro." It is a small real-mode 386 rendering pipeline: fixed-point transform, normal generation, visible-face collection, radix-like depth ordering, table-textured spans, table-based compositing, and hand-packed planar VGA output. The S3M player and manual sound setup are conventional for the era; the interesting signature is the way Complex fit a reasonably complete renderer and timeline into the RNC-packed 64K envelope.
Static Analysis Limits
The static pass recovered the major loops and data flow, but some artistic labels remain inferred:
- The recurrence table at
0x40beis clearly sampled as a compact generated signal, but I am not assigning it a precise sine/noise formula name without a source-level derivation. - The object records at
cs:09a8are structurally decoded enough to follow transform, culling, and rendering, but their scene/artist names are not stored in the archive. - The generated image path at
0x347fis described by its actual sampling loop and symmetry; a frame capture would be the better place to name the exact visible effect.
Those limits do not affect the central loop analysis: the sound setup, S3M loader, timer path, transform/projection, face collector, rasterizer, block compositor, and VGA copy are all tied to concrete offsets and data paths in the RNC-expanded image.