Analysis model: gpt-5.5 xhigh
Internal Damage by Electromotive Force - Technical Dissection
Scope
This is a reverse-engineering pass over Internal Damage by Electromotive Force, an MS-DOS VGA demo released at Assembly 1992. Demozoo lists it as released on 26 July 1992 and as the 3rd-place entry in the Assembly 1992 PC Demo competition. Pouet also lists it as a July 1992 MS-DOS demo by Electromotive Force, ranked 3rd at Assembly 1992.
Public references:
- Demozoo production: https://demozoo.org/productions/6390/
- Pouet production: https://www.pouet.net/prod.php?which=4182
- Demozoo Assembly 1992 PC Demo competition: https://demozoo.org/competitions/183/
- Scene.org archive entry: https://files.scene.org/view/parties/1992/assembly92/demo/emf_id.zip
- Direct archive URL used here: https://archive.scene.org/pub/parties/1992/assembly92/demo/emf_id.zip
The binary is PKLITE-packed and the usual direct unpack attempts did not produce a useful on-disk decompressed executable. The detailed offsets below therefore refer to a 16 MB DOSBox-X guest RAM carve captured after runtime unpacking, unless a section explicitly says file offset. That means these are not original file offsets. They are flat offsets in the recovered guest memory image.
The demo's own credit strings name sections such as the menu system, music system, x-faded logos, eagle intro, sineballs, parallax, vectorballs, colorbar scroll, and final part. This pass resolves several of the central VGA and inner loops, but it does not pretend to be a full source reconstruction of every visual part. Where a part target looked like copied data or segment-aliased code in the capture, I have left it as a boundary rather than inventing a story.
Examined Archive
Downloaded archive:
138a0b81b562883eb5c2d48019511c2010467ae7f2e115aaaa9a50659e618bda emf_id.zip
Files:
| File | Size | SHA-256 | Notes |
|---|---|---|---|
EMF_ID.EXE |
151,364 | ce7d73bf4b5fabf39ab93798439ef23d9ebf0dc24667b2fe3a2ce3fd643ede85 |
Main demo, MZ executable, PKLITE-packed |
FILE_ID.DIZ |
57 | 8046fd8e8555f94f23b3464942b29ad2e14d3cb4c1be13ddf15a539a9396c846 |
Small release description |
The main executable is an MZ program. Its header contains the PKLITE marker:
!PKLITE Copr. 1991 PKWARE Inc. All Rights Reserved
MZ header facts:
| Field | Value |
|---|---|
| File size | 151,364 bytes |
| Computed MZ image size | 151,364 bytes |
| Header size | 0x90 bytes |
| Relocations | 0 |
| Entry | 24c8:0077 |
| Entry file offset | 0x24d87 |
| Stack | 24c8:0075 |
| Min alloc | 0x65ae paragraphs |
| Max alloc | 0xffff paragraphs |
| Overlay number | 0 |
The file has no separate data files. Everything needed by the demo is packed
inside EMF_ID.EXE.
Runtime Unpack Capture
PKLITE -x and UNP were both run under DOSBox-X and both returned without
producing a changed executable. The useful route was to run the demo under
DOSBox-X, interrupt the host with gdb, dump the host process core, and carve
the DOS guest memory by locating the DOS COMSPEC=Z:\COMMAND.COM environment
marker.
The carve produced:
/tmp/internal-damage-analysis/guest_ram.bin
size: 16,777,216 bytes
The PKLITE marker is present in the packed EXE but absent from the carved guest RAM, which is exactly what we want: the runtime image contains unpacked code and data.
Useful strings in the carve:
| Guest offset | String evidence |
|---|---|
0x007a64, 0x007cc9 |
EMF_ID.EXE |
0x02e128 |
credit block |
0x04dfe9 |
Purple |
0x04e009 |
Motion-91 |
The credit block identifies the usual roles:
- menu and graphics by Dr. Lizard, with code by Devastator
- music system code by Skyrider and Devastator
- x-faded logos and eagle intro involving Dr. Lizard, Saracen, and Devastator
- sineballs, parallax, vectorballs, and colorbar scroll as named parts
- music by Purple Motion
- contact address through Druid of EMF
Recovered Memory Layout
The main low-memory nonzero ranges below 0x80000 are:
| Range | Size | Notes |
|---|---|---|
0x009342..0x01252c |
0x91ea |
loaded low code/data |
0x013437..0x01906c |
0x5c35 |
loaded data |
0x01a010..0x01c433 |
0x2423 |
loaded data |
0x01cba4..0x020341 |
0x379d |
loaded data |
0x0217f2..0x024473 |
0x2c81 |
loaded data |
0x0296e6..0x02b015 |
0x192f |
loaded data |
0x0306f2..0x032026 |
0x1934 |
loaded data |
0x032d92..0x0364ab |
0x3719 |
loaded data or segment-aliased code |
0x036716..0x03b5d2 |
0x4ebc |
loaded data or segment-aliased code |
0x03c3bf..0x047db5 |
0xb9f6 |
strongest contiguous unpacked code island |
0x047f37..0x04bf34 |
0x3ffd |
data/code island |
0x04dd36..0x07a6ec |
0x2c9b6 |
larger packed resources, music/data |
The reliable code island for this pass is the range around
0x03c3bf..0x047db5. It contains BIOS mode switches, direct VGA register
writes, IRQ handlers, palette loaders, and the resolved inner loops described
below.
Hardware anchors in the carved image:
| Pattern | Representative offsets | Meaning |
|---|---|---|
int 10h ax=0013h |
0x3cb93, 0x3ce15, 0x3d1d0, 0x3d717, 0x3f738, 0x43b6c, 0x45b5f, 0x46278 |
Mode 13h or tweaked Mode X setup starts |
3c8h/3c9h DAC writes |
0x3cd26, 0x3d648, 0x3f7a5, 0x43a98, 0x45d74, 0x46381 |
palette upload/fade/rotation |
Sequencer 3c4h |
many offsets, including 0x3d287, 0x3fa83, 0x45c08, 0x46324 |
plane masks, memory mode, planar writes |
Graphics controller 3ceh |
0x3d39c, 0x3fbd5, 0x41bf6 |
write mode and odd/even control |
| A000 segment loads | 0x3cb8e, 0x3d599, 0x3e4b5, 0x4398d, 0x4612d |
direct VGA framebuffer access |
Top-Level Dispatcher
The most useful top-level routine begins around guest offset 0x3ca16. Its
shape is:
3ca16: call 3cb08 ; CPU probe
cmp ax,0003
jae ok
; print error and exit if less than 386-ish
ok:
call 3cb76 ; menu/system setup
; several far calls through a patched audio/player entry
; stores timing/audio state in cs:00ee and cs:00f0
part_loop:
eax = [cs:006b]
bx = [cs:00f0]
call 3d096 ; projected-dot / intro style part
eax = [cs:006b]
bx = [cs:00f0]
call 3d5f6 ; second projected-dot part with palette rotation
eax = [cs:006b]
bx = [cs:00f0]
call 3e506 ; text/palette/sprite part
eax = [cs:006b]
bx = [cs:00f0]
cx = [cs:00ee]
call 339e6 ; target not resolved safely in this capture
eax = [cs:006b]
bx = [cs:00f0]
cx = 08a2
call 35a26 ; target not resolved safely in this capture
call 36186 ; returns ZF/NZF to continue or exit
jne part_loop
The calls after 0x3e506 do not disassemble cleanly as flat offsets in this RAM
snapshot. They may be segment-relative code, copied code, or overwritten by data
at the capture point. I am not assigning them visual names here.
The CPU probe at 0x3cb08 is also worth noting. It temporarily swaps exception
vectors and tries 386+ instructions such as xadd, smsw, and mov cr0 to
decide whether the machine is acceptable. This is more than a passive version
check; it actually probes instruction behavior and then restores the vectors.
Shared Menu, Input, and Palette System
The setup routine at 0x3cb76 is the first large recovered system routine. It
sets DS=ES=08a2, installs a keyboard IRQ handler, clears the DAC, draws the
menu graphics, and runs a keyboard-controlled loop.
Keyboard IRQ
IRQ1 installation at 0x3cd9c:
cli
ds = 0000
save word [0000:0024] into [0060]
save word [0000:0026] into [0062]
write offset 03c9, segment CS to IVT vector 09h
sti
The handler at 0x3cddf is a compact raw PC keyboard handler:
in al,60h
test al,80h
jnz release_key
mov [0064],al ; keep last make code only
release_key:
in al,61h
or al,80h
out 61h,al
and al,7fh
out 61h,al ; keyboard acknowledge pulse
mov al,20h
out 20h,al ; PIC EOI
iret
There is no BIOS keyboard queue here. The parts poll a single byte updated by
the interrupt. That is why later loops can use simple comparisons such as
cmp byte [key],1.
Vertical Retrace Waits
The menu and later parts use the VGA input-status register at 3dah:
wait_vblank_set:
inc word [frame_counter]
dx = 03dah
.spin:
in al,dx
test al,08h
jz .spin
ret
wait_vblank_clear:
dx = 03dah
.spin:
in al,dx
test al,08h
jnz .spin
ret
The code normally does work between the two waits. This gives it a coarse frame counter and makes DAC/CRTC changes land in predictable parts of the frame.
RLE Decoder
The simplest menu/image decoder is at 0x3cc6a. It uses ffh as a run marker:
decode:
lodsb
cmp al,0ffh
jne literal
lodsw ; AL = byte, AH = count
mov cl,ah
rep stosb ; write AL, CL times
cmp si,bx
jb decode
ret
literal:
stosb
cmp si,bx
jb decode
ret
There are two related variants:
0x3cfcc: same RLE format, but nonzero bytes are offset byDLbefore writing. This lets one compressed image be recolored by changing a bias value.0x3cff0: same RLE format, but writes by adding into the existing screen byte. This is an additive overlay decoder rather than a replacement blitter.
The common design is practical for 1992 DOS demos: compressed pictures in the EXE, a tiny unpack loop, and no multiplication in the draw path.
Palette Upload and Fade
The basic palette upload at 0x3cd26:
dx = 03c8h
out dx, al ; starting DAC index
inc dx ; 03c9h
rep outsb ; write RGB triples
for each palette entry:
ax = byte [di] * 2 + word [bp]
[bp] = ax
[si] = ah
si++, di++, bp += 2
The first half is a normal DAC upload. The second half is more interesting: it acts like a small integer accumulator or low-pass stepper. A byte table feeds a word accumulator; the high byte becomes the next palette byte. This produces smooth palette drift without expensive division.
0x3cd4b is the simple fade-down path. Every other frame it uploads the current
palette and decrements bytes that are still positive. 0x3cd6d reads the
current DAC state back into RAM using 3c7h/3c9h, and 0x3cd8e clears all 768
DAC bytes to zero.
VGA Model: Mode 13h as a Starting Point, Then Planar Tricks
Several parts call BIOS mode 13h, then immediately reprogram VGA registers. The common pattern is:
mov ax,0012h
int 10h
mov ax,0013h
int 10h
dx = 03c4h
ax = 0604h
out dx,ax ; sequencer memory mode
; attribute controller and CRTC changes follow
The result is not plain chunky mode 13h. The code uses sequencer map masks, graphics-controller write mode changes, CRTC start-address scrolling, and alternate A000/A300/A400/A600-style segments. In practice the demo keeps the convenience of 320-wide VGA timing while drawing through planar masks when that is faster or easier.
This matters for the inner loops: many loops write one byte but select which plane receives it with sequencer register 2. X coordinates are therefore often:
byte_address = line_offset + (x >> 2)
plane_mask = 1 << (x & 3)
That exact pattern appears in the projected-dot loops.
First Projected-Dot Part at 0x3d096
This part sets DS=1909, ES=A000, patches several far-call stubs with an
audio callback pointer, installs its IRQs, configures the tweaked VGA mode, and
then runs a projected point loop until the key byte says to exit.
Important setup values:
| Field | Value | Meaning |
|---|---|---|
FS:8251 |
0x6000 |
CRTC start/page offset |
FS:8253 |
0x0050 |
destination column base |
FS:8255 |
1 |
small frame/modulo counter |
| point count | 0x190 |
400 points, stored as word arrays |
CRTC Start and Column Reveal
Routine 0x3d21c writes the CRTC display start from FS:8251, increments it,
then calls a planar column copier:
bx = [fs:8251]
dx = 03d4h
out dx, 0c00h | bh ; high byte of CRTC start
out dx, 0d00h | bl ; low byte of CRTC start
inc word [fs:8251]
call 3d287 ; draw next sparse column
The CRTC start write gives a cheap hardware scroll/page movement. The column copier fills in new data a little at a time.
The core of 0x3d287 is an unrolled planar copy. In pseudocode:
mask = 1;
for (plane = 0; plane < 4; plane++) {
outw(0x3c4, 0x0200 | mask); // sequencer map mask
di = state.dest_column;
si = state.source_column;
for (row = 0; row < about_40_rows; row++) {
vram[di] = source[si];
si += 0x20; // next source row/strip
di += 0x51; // next destination scan-ish row
}
mask <<= 1;
state.source_column++;
state.dest_column++;
}
The actual code is mostly repeated movsb, add si,001fh, add di,0051h
blocks rather than a compact counted loop. That saves branch overhead and lets
the author tune the exact row count. The stride 0x51 is a strong sign that the
destination is a tweaked planar layout, not a plain 320-byte chunky screen.
Point Initialization
0x3d45d initializes 400 points. Each point has separate word arrays for x, y,
z, previous address, and previous plane mask. The random source at 0x3d482
mixes PIT timer ports 40h, 41h, and 42h with a stored seed:
in al,40h
mov bl,al
in al,41h
xchg al,bh
in al,42h
add bx,[seed]
rol bx,1
mov [seed],bx
ret
The exact instruction order is slightly different, but the important behavior is that it is hardware-timer noise plus feedback. That is enough for randomized point placement without shipping a random table.
Projected Point Inner Loop
The most important loop is 0x3d399. It is a direct 3D point projector with
per-point erase state:
for si = 031eh down to 0000 step -2:
old_mask = [si + 0ca8h]
if old_mask != 0:
out sequencer map mask = old_mask
es:[old_address] = 0
z = [si + 0668h] - 3
[si + 0668h] = z
if z <= 0:
randomize x,y,z
continue
ax = [si + 0348h] ; y
cwd
idiv z
ax += 45
if ax < 0 || ax >= 80:
continue
di = word [0fc8h + ax*2] ; scanline/row table
ax = [si + 0028h] ; x
cwd
idiv z
ax += 160
if ax < 0 || ax >= 320:
continue
di += ax >> 2
plane = 1 << (ax & 3)
out sequencer map mask = plane
if es:[di] == 0ffh:
[si + 0ca8h] = plane
[si + 0988h] = di
es:[di] = (z >> 3) + 50h
This is a good early-1990s PC demo inner loop:
- no full-screen clear
- each point carries its previous plane and byte address
- erasing is one masked byte write
- projection uses signed integer division by
z - brightness comes from depth
- planar x addressing uses
x >> 2plus1 << (x & 3)
The es:[di] == 0ffh test is a simple collision/availability check. It avoids
overwriting pixels that the part considers occupied. Since the previous address
is saved only when a point is actually drawn, the erase path stays cheap.
Second Projected-Dot Part at 0x3d5f6
The second projected-dot routine is structurally similar, but uses a different
data segment (DS=1c46) and fewer points.
Important arrays:
| Array | Offset expression | Meaning |
|---|---|---|
| x | si + 02dch |
source x |
| y | si + 03cch |
source y |
| z | si + 04bch |
depth |
| previous address | si + 05ach |
byte address in VRAM |
| previous plane | si + 069ch |
sequencer map mask |
Projection differences:
point count: 0x78 words
yscreen = y / z + 0x6e
visible y: 0 <= yscreen < 0x6e
xscreen = x / z + 160
brightness = (z >> 3) + 0x50
line table = 0x078c + yscreen * 2
The draw/erase logic is the same design as the first part. The value in having two separate implementations is that each part can tune point count, projection center, line table, palette, and scripted control without paying for a generic engine.
Palette Rotor
0x3d816 rotates a 0x60-byte palette strip at DAC index 0xb0:
offset -= 3
if offset wrapped:
offset = 0x5d
out 3c8h, 0b0h
rep outsb from 0ac4h + offset, count depending on wrap
rep outsb from 0ac4h, remaining bytes
It rotates by RGB triples, not by single bytes. That keeps palette entries aligned as colors while still using the DAC as the animation engine.
Scripted Tile/Pattern Updates
0x3d837 calls a small restore/draw helper for six saved screen positions, then
uses a script stream at 0x01d4 + [01d2] every 0x100 ticks. The script bytes
patch immediate values inside the local code near 0x0f13 and 0x0f17.
The safe reading is:
- the part has self-modifying scripted motion or pattern control
- it updates a few saved rectangular/tile positions per frame
- the script changes drawing parameters without going through a slower generic interpreter
I am deliberately not naming the visible object here because the code proves the scripted update mechanism more strongly than it proves a visual label.
Text, Palette, and Bouncing Sprite Part at 0x3e506
The routine at 0x3e506 is another complete visual part. It sets DS=2015,
ES=A000, patches audio callback stubs, initializes motion bounds, sets a
tweaked VGA mode, converts image data into planar form, pre-fills the display,
then enters a frame loop:
frame:
call 3f724 ; optional IRQ/PIC/audio timing wrapper
call 3f6f3 ; wait for vertical retrace, increment frame counter
call 3f77e ; CRTC start, palette rolls, text/glyph strip
call 3f724
call 3faee ; two moving masked objects
loop until key byte == 1
Stronger Tweaked VGA Setup
0x3f733 does the same broad mode switch as earlier parts, then pushes a fuller
VGA setup:
int 10h ax=0012h
int 10h ax=0013h
out 3c4h, 0604h ; sequencer memory mode
out 3c4h, 0100h ; sync reset
out 3c2h, e7h ; misc output
out 3c4h, 0300h ; restart sequencer
attribute controller:
reg 10h = 61h
reg 11h = 00h
CRTC:
unlock reg 11h
output 0x14 words from a local CRTC table
The CRTC table and later page-start writes show this part is built around a custom planar display layout rather than plain mode 13h.
CRTC Start and Palette Bands
0x3f78b writes the CRTC start from [16ee], then increments it:
bx = [16ee]
out 3d4h, 0c00h | bh
out 3d4h, 0d00h | bl
inc word [16ee]
0x3f7a1 uploads many 24-byte palette bands from tables such as 1a3f,
1a6f, and following offsets. It also uploads a 0x30-byte band at DAC index
0xf0 from 1cdf + [23a]. Both [16ec] and [23a] decrement by 3 and wrap,
which again means the animation step is one RGB entry at a time.
There is also a conditional upload:
if [16f8] != 0:
upload 0x90 bytes at DAC index 0x10
clear [16f8]
That lets the text script trigger a larger palette change on a specific command.
Planar Source Converter
Before the strip renderer runs, 0x3fa83 converts two blocks of packed data
into A300-planar memory:
es = A300h
for block in [(di=0000, si=1d3f), (di=0100, si=1d43)]:
bp = 0x77
while bp--:
ax = 1102h ; sequencer index 2, mask starts in AH
for 4 plane writes:
out 3c4h, ax
movsb
rol ah,1
adc di,-1 ; advance byte address on plane wrap
si += 4
The rol ah,1 plus adc di,-1 trick is compact. As the map mask rotates across
planes, the carry from the rotate decides whether the byte address should step.
That converts interleaved source bytes into the layout expected by the later
planar renderer.
Glyph/Text Strip Renderer
0x3f874 is one of the clearest inner loops in this demo. It draws short
vertical glyph strips into A400/A300-style planar memory with a fixed row stride.
The simplified logic:
enable_graphics_controller_write_mode_variant();
es = A400;
ds = A300;
bp = 0x1bfd + text_page + subframe_offset;
cx = horizontal_phase;
bl = 0;
while (bl < 0x70) {
ch = cs[bp];
if (ch == '.')
si = phase_base + 0;
else if (ch == 's')
si = phase_base + 7;
else
si = phase_base + bl + 0x0e;
di = line_table_or_phase(cx);
repeat 7 times:
*di++ = *si++;
di += 0x5b;
cx += 0x0284;
bp += 0x000a;
bl += 7;
}
The actual code is branchy and unrolled around the seven byte writes, but the
shape is exactly this: pick one of a few source glyph columns, write seven bytes
vertically, stride by 0x5b, then advance to the next glyph column.
The script side runs every other frame:
inc [16f0] ; horizontal phase each call
if odd/even frame says no:
return
[16f4]++
if [16f4] != 0x0a:
return
[16f4] = 0
cmd = [16fa + [16f6]++]
if cmd == 0:
[exit_key] = 1
reset strip state
render about 0x80 flush frames
elif cmd == 1:
[16f8] = next word ; palette-change pointer
else:
glyph_page = (cmd - 'A') * 0x0a0
if cmd < 'A':
glyph_page = 0x1a page
This is a compact text animation engine. The display loop is just a tight planar strip renderer; the script only has to change which glyph page and palette data are feeding it.
Two Moving Masked Objects
0x3faee updates two moving objects. The parameters initialized at part start
are:
x1 = 0x004e, y1 = 0x00c8, dx1 = -2, dy1 = 2
x2 = 0x000a, y2 = 0x00b2, dx2 = 6, dy2 = 6
Per frame:
erase previous object at [023c]
erase previous object at [023e]
draw object 1 using y table 20f7h, x coordinate [022a]
draw object 2 using y table 20f7h, x coordinate [022c]
if y1 < 6 or y1 >= 0xae: dy1 = -dy1
if y2 < 6 or y2 >= 0xae: dy2 = -dy2
if x1 < 2 or x1 >= 0x116: dx1 = -dx1
if x2 <= 2 or x2 >= 0x116: dx2 = -dx2
x += dx
y += dy
The helper at 0x3fbad converts x/y to planar address and plane phase:
edi = y
di = word [0022h + edi*2] ; line offset table
di += x >> 2
[previous_address + bp] = di
phase = x & 3
si = phase * 0x16
ds = AE00h
set graphics controller write mode bit
select sequencer map mask index
jump through phase-specific generated code
The final jump goes to generated or segment-resident mask code that is not present as normal low-memory code in this capture. The verified part is still enough to identify the classic strategy: erase by previous address, compute planar byte plus x phase, then dispatch to one of four shifted mask/draw kernels.
Parallax/Page-Strip Part Around 0x45b5a
The code island around 0x45b5a is another full VGA part. It sets mode 13h,
programs sequencer and CRTC registers, decodes image data, scrolls by changing
the CRTC start, draws a new strip, and rotates palettes.
Setup and RLE Load
The setup at 0x45b5a:
int 10h ax=0012h
int 10h ax=0013h
out 3c4h, 0604h
out 3c4h, 0100h
out 3c2h, e7h
out 3c4h, 0300h
unlock CRTC register 11h
output 0x11 words from a CRTC table
The local RLE loader at 0x45bad is the same ffh marker design as the menu:
lodsb
if al == ffh:
lodsw
cl = ah
rep stosb al
else:
stosb al
repeat until si >= bx
This appears to feed a staging buffer at 082fh from compressed art selected by
a small script at [0046].
CRTC Scroll
0x45bc5 computes a display start offset from a sine/table value:
bx = ([082d] + 2) & 01feh
[082d] = bx
ax = word [0629h + bx]
dx:ax = signed ax
ax /= 0x5a
ax *= 0x5c
bx = [0044] - ax
out 3d4h, 0c00h | bh
out 3d4h, 0d00h | bl
This is a hardware vertical/page wobble: a table controls the CRTC start address instead of moving pixels.
Strip Copier Inner Loop
The most important part is 0x45bf5. It draws a new strip into the scrolled
view using all four VGA planes.
Simplified:
es = [0042];
si = 0x082f + [00b7]; // staged source plus suboffset
di = [0044] + 0x005a; // destination follows current page start
outw(0x3c4, 0x0f02); // enable all maps for clearing edge bytes
clear es:[page_start - 2];
clear es:[page_start + 0x3250];
height_or_width = [00b6];
bp = (height_or_width * 0x68) >> 1;
bx = height_or_width - 1;
if ([0044] < 0x6330) {
repeat 2 bands:
repeat 4 planes:
out sequencer map mask
repeat 0x34 rows:
movsb
si += bx
di += 0x5b
mask <<= 1
si -= bp
di -= 0x12b0
si += bp
si -= 3
di += 0x12b0
} else {
same idea, but also mirrors/copies bytes to a wrap buffer
}
The constants reveal the layout:
0x34rows per plane pass0x5bdestination stride0x12b0equals0x5b * 0x34, the amount needed to rewind one vertical plane pass- four map-mask passes cover the four VGA planes
- the late path handles wraparound when the destination reaches the high page
threshold around
0x6330
This is parallax/page-strip code: hardware scroll moves the visible page, and the routine paints the newly exposed strip in planar form.
Palette Rotation and Color Bars
0x45d5b rotates two palette bands:
if (--[0284] == 0) {
[0284] = 2
out 3c8h,80h
write rotated 0x30 bytes from 05c9h
out 3c8h,90h
write rotated 0x30 bytes from 05f9h
}
out 3c8h,c0h
write 0xc0 bytes from 0305h
out 3c8h,00h
write 0xc0 bytes from 35e3h
0x45dc5 builds the palette source at 0305h, updates five phase bytes, and
copies 24-byte strips from a lookup table. This makes the visible color bars
mostly a palette problem: the pixel data can stay relatively static while the
DAC entries move.
Final Text/Crawl Compositor Around 0x46186
The island around 0x46186 is a later or final text compositor. It sets
DS=2e13, ES=A000, patches three far-call stubs with the audio callback, and
installs its own keyboard/vector state. It then loops:
loop:
wait_vblank_set
if frame_counter is even:
call 46308 ; draw text/glyph block
call 462dd ; update CRTC start
wait_vblank_clear
if key == 1 or key == 2:
exit
Text Block Renderer
0x46308 draws 16 characters per slice:
si = [0024] ; text pointer
di = [0028] ; destination/page pointer
bp = 0x10 ; 16 characters
while bp--:
ch = *si++ - 0x20
glyph = 0x0686 + ch * 0x220 + [0026]
dx = 03c4h
ah = 11h ; starting plane mask pattern
cx = 0x10 ; 16 columns/plane steps
while cx--:
out 3c4h, 0200h | ah
al = *glyph++
es:[di] = al
es:[di - 0x3ed0] = al
rol ah,1
adc di,0
di++
After drawing the slice:
[0028] += 0x50
[0026] += 0x10
if (--[0020] == 0) {
[0020] = 0x22
[0024] += 0x10
[0026] = 0
if (--[0022] == 0) {
[0022] = 0x64
[0024] = 0x2e
key = 2
}
}
So this is a timed text/crawl system:
[0024]selects the text/glyph stream[0026]selects the vertical glyph slice[0028]selects the destination page position[0020]and[0022]are counters controlling when to advance and when to stop- each byte is written twice, once at
diand once atdi - 0x3ed0, giving a repeated/wrapped copy on another page area
CRTC Movement
0x462dd moves the visible start:
[002a] += 0x50
if [002a] > 0x3e80:
[002a] = 0
[0028] = 0x3e80
bx = [002a]
out 3d4h, 0c00h | bh
out 3d4h, 0d00h | bl
Again, visible scrolling is mostly a CRTC start-address change. The renderer only has to keep feeding new text slices into the ring.
What the Demo Is Doing Overall
The recovered code shows a consistent engine style:
- Use PKLITE to fit a self-contained executable into a party-friendly archive.
- Start from BIOS mode 13h, then reprogram VGA into custom planar layouts.
- Use CRTC start-address changes for scrolling and page motion instead of copying the whole framebuffer.
- Use sequencer map masks for x-phase and planar drawing.
- Animate many colors through DAC rotation rather than repainting pixels.
- Keep sprite/point erase cheap by storing previous addresses.
- Use tiny scripts and self-patched immediates where a generic interpreter would cost too much.
- Patch audio callback far calls into the visual parts so music can be ticked from several long-running loops.
The most characteristic inner loops are the projected point renderer
(0x3d399), the planar column/strip copiers (0x3d287, 0x45bf5), the glyph
strip renderer (0x3f874), and the text compositor (0x46308). These are all
written in the usual style of high-end 1992 PC demo code: branch-light,
hardware-aware, state kept in parallel arrays, and almost never doing a full
screen memory operation when a CRTC register or DAC update can do the work.
Remaining Unresolved Areas
This pass does not fully reconstruct every named credit part. In particular:
- Some dispatcher targets after
0x3e506did not resolve as sane flat code in this capture. - The phase-specific masked sprite kernels reached by
0x3fbadappear to be segment-resident or generated code outside the simple low-memory flat offset used in this pass. - The audio system was only identified through patched far-call sites and lifecycle calls, not reconstructed as a player.
- The exact mapping between every credit label and every code island still needs more timed captures or an emulator-side trace.
The core VGA tricks are clear, though: this demo leans heavily on Mode X-style plane masks, CRTC start-address scrolling, DAC rotations, compact RLE assets, and per-object previous-position erasing.