Analysis model: gpt-5.5 xhigh

# Bip 4 the Future by The Binary Poets - Technical Dissection

## Scope

`Bip 4 the Future` is a 1993 MS-DOS trackdemo by The Binary Poets. The
Computer Crossroad 1993 results list it as an unranked PC demo compo entry. The
release text says the public package was released on June 10, 1993, after the
party, and that the party version was later improved with additional shade and
morphing material.

Public references:

- Scene.org archive:
  https://archive.scene.org/pub/parties/1993/computer_crossroad93/demo/bip4fut.zip
- Scene.org TCC 1993 demo directory:
  https://archive.scene.org/pub/parties/1993/computer_crossroad93/demo/
- Scene.org TCC 1993 results:
  https://archive.scene.org/pub/parties/1993/computer_crossroad93/results.txt

This writeup is based on the scene.org archive, the bundled release text,
custom unpacking of `BIP4FUT.EXE`, file layout inspection, and static 16-bit
disassembly of the expanded runtime image. It is not a source-level rebuild.

Old private contact listings from the release text are deliberately omitted.

## Release Notes And Requirements

The release text is unusually explicit about the development target:

- Release year: 1993.
- CPU: 80286, with faster 386/486 machines recommended.
- Video: standard VGA.
- Memory: about 560 KB free conventional memory.
- Audio: PC speaker, mono or stereo D/A on printer ports, Sound Blaster, and
  Sound Blaster Pro.
- Code: described by the authors as their first 100 percent assembler demo.
- Tools: Turbo Assembler, Deluxe Paint II, 3D Studio, WinImages Morph, and TCB
  Whacker Tracker.
- Music system: GoldPlay by Sourcer of The CodeBlasters.

The code matches those notes. It is a real-mode 286-style program using BIOS
mode `13h`, direct VGA DAC writes, direct A000 blits, DOS file reads, and a
resident GoldPlay block for module playback. It does not use a protected-mode
runtime or an FPU.

## Examined Files

Archive hash:

```text
5c457d8e1c28cfd17a6ea83016f157d3ccc1ed046945305cda70db3c5b449b75  bip4fut.zip
```

Extracted files:

```text
BIP4FUT.001  256000 bytes  raw visual data, four 64000-byte frames
BIP4FUT.002  139722 bytes  ProTracker M.K. module, title "BIP 4 THE FUTURE"
BIP4FUT.EXE   71096 bytes  packed MZ executable
BIP4FUT.TXT    7833 bytes  release text
README.BAT       41 bytes  text viewer batch file
FILE_ID.DIZ      58 bytes  short release description
```

Extracted hashes:

```text
d769806a11facd2f84f80293e64c2a851c3acc6bb6179f4e0a06b295d48e1e24  BIP4FUT.001
5cafd217f1c74ed07b6f4b1a9186cf008861a4d4b60bfc66cf4765c80b990b20  BIP4FUT.002
e5ded08aedb9a0b5f3864ecd33092f4b52c7b089b504b970cd218343b683e5aa  BIP4FUT.EXE
5d3e3912d2acc3f7a1ee3a75a88a8d9a4338de29e08d9b9929f231a6fcf632ee  BIP4FUT.TXT
0f533a5d24e10cd85851a5de7674d94f97a4a9a512cabf22e84a333b82fa599f  README.BAT
2f4da7a614f0e7eb807dec4655cb3f8a8059a598404fd5e5998332860fac4d79  FILE_ID.DIZ
```

`BIP4FUT.001` is exactly `4 * 64000` bytes, which fits four complete
320x200x8bpp mode-13h frames. The runtime does not display each frame as one
full screen. It reads one 64000-byte chunk at a time, then reveals eight
80x100 tiles from that chunk.

## MZ Wrapper And Packed Entry

The executable starts as a normal MZ program:

```text
File size:         71096 bytes
MZ image size:     71096 bytes
Header size:       144 bytes
Relocations:       0
Entry CS:IP:       111a:0100
Entry file offset: 0x11330
Stack SS:SP:       115c:0400
Min/max alloc:     33b4/ffff
```

The zero relocation count is a sign that the visible MZ image is not the final
program. The entry is a custom packer stub. It first moves the packed image to
high conventional memory, then far-returns into the relocated copy at offset
`016ch`.

The high-copy loop is backward and segment based:

```asm
std
si = fffeh
di = fffeh
dx = cs + 0039h
bx = high_destination_segment

copy_loop:
  choose up to 1000h paragraphs
  dx -= 1000h
  bx -= 1000h
  ds = dx
  es = bx
  rep movsw
  repeat until all selected paragraphs are copied
```

The backward direction matters because the destination can overlap the loaded
program. Copying from the end avoids destroying input bytes before the packer
has moved them.

After the copy, the stub leaves the original program segment on the stack,
pushes `016ch`, and executes `lret`. The depacker then runs from the relocated
copy while writing the expanded image back to the normal DOS load area.

## Custom Depacker

The depacker begins at packed file offset `0x1139c`, which is offset `016ch` in
the packed code segment. It computes the input stream segment by subtracting
the original MZ `CS` value:

```asm
mov ax,cs
sub ax,cs:[0386h]   ; [0386h] = 111ah
mov ds,ax
mov di,0100h        ; PSP:0100 == load image offset 0
xor si,si
lodsw
xchg ax,bp          ; first 16-bit bit buffer
mov dx,0010h        ; bits remaining
```

The output pointer is `ES:DI`, with `ES` still set to the PSP segment. Since
`PSP:0100` and `(PSP+10h):0000` are the same physical byte, the output begins
at load-image offset zero.

The main bit loop is a compact LZ copy scheme:

```text
get one bit from BP
if bit == 0:
  copy one literal byte from input to output
else:
  decode match length from bit fields and tables
  decode match distance from high bits/table plus one low input byte
  copy match_length bytes from output_pointer - distance
```

The bit reader is repeated inline many times:

```asm
shr bp,1
dec dx
if dx == 0:
  lodsw
  xchg ax,bp
  mov dl,10h
```

Because `lodsw`, `xchg`, and `mov` preserve the carry flag, a bit can be
shifted out, the bit buffer can be refilled, and the next `rcl bx,1` still sees
the bit that was just consumed. That is why the code contains many small
reload labels instead of a normal callable bit-reader routine.

The match-length tables live in the packed stub:

```text
0347h  short length table
0352h  extended length table
035dh  second extended length table
036dh  high-distance table
```

The copy body is the expected overlapping LZ copy:

```asm
lodsb               ; low distance byte
mov bl,al
push ds
push si
push es
pop  ds
mov si,di
sub si,bx           ; source is already-expanded output
rep movsb
pop si
pop ds
```

There are two special tokens. Length code `19h` reads an extra byte. If that
extra byte is `feh`, the depacker normalizes both input and output segment
pairs without changing the physical pointer:

```asm
bx = di
di = (di & 000fh) + 2000h
es = es + (bx >> 4) - 0200h

bx = si
si = si & 000fh
ds = ds + (bx >> 4)
```

This lets the 16-bit near offsets stay small while the physical stream keeps
moving forward. If the extra byte is `ffh`, decompression ends and the trailer
is parsed.

The local unpack produced:

```text
Expanded load image: 282356 bytes
Input bytes consumed: 70290 bytes
Relocation records: 23
Final SS:SP: 0000:1000
Final CS:IP: 3ac6:0000
Entry offset in expanded image: 0x3ac60
Expanded image hash:
9f5529f3d284e01ba33ee3fb8cc46dc4db8ad69364da77984e54f83ae0b540d3
```

The relocation trailer patches segment words in the expanded image. For the
analysis below, offsets are raw expanded-image offsets. When a word such as
`0100h` is relocation-marked, the real DOS run adds the load segment to it.

Important relocation-marked words include:

```text
0x3ac68  DS reset for local data
0x3ac88  GoldPlay far-call segment
0x3ac90  GoldPlay module-load segment
0x3acaa  GoldPlay start segment
0x3ad4d  visual-data source segment
0x3c076  visual-data source segment
0x3c261  file-read buffer segment
```

## Top-Level Runtime Flow

The expanded entry at `0x3ac60` starts by shrinking the DOS memory block,
setting local data, switching to text mode, and hiding the cursor:

```asm
mov ah,4ah
mov bx,493eh
int 21h

mov ax,0100h        ; relocation-marked: local data segment
mov ds,ax

mov ax,0003h
int 10h

mov dx,03d4h
mov al,0ah
out dx,al
mov dx,03d5h
mov al,20h          ; hide text cursor
out dx,al
```

It then runs the menu/setup path, writes the selected audio parameters into
GoldPlay's variables, loads the module, and starts mode `13h`:

```asm
call 3b624h         ; text setup/menu path
call 3b79ah         ; write GoldPlay setup words
lcall 3c37:4931     ; GoldPlay initialization
mov dx,1d10h        ; "bip4fut.002"
lcall 3c37:3f9d     ; module load
mov ax,0013h
int 10h
call 3bfddh         ; upload working palette
lcall 3c37:4137     ; start playback/timer path
```

The visual sequence is mostly a long linear script. It alternates between:

- bulk copies from image data to A000;
- palette table swaps, ramps, and fades;
- retrace waits;
- coordinate-table effects using 36 moving points;
- 16x16 sprite stamps;
- sparkle pixels and cleanup passes;
- the streamed `BIP4FUT.001` tile reveal;
- a final text-band scroller.

At the end, it unmasks the PIC, calls two GoldPlay shutdown routines, restores
text mode, moves the cursor, and exits through DOS.

## GoldPlay Setup

The setup writer at `0x3b79a` stores menu choices into the relocated GoldPlay
segment:

```asm
mov ax,3c37h        ; relocation-marked
mov es,ax
mov bx,[16a0h]
mov es:[095ah],bx
mov bx,[16a2h]
mov es:[095ch],bx
if word [0960h] != 0:
  mov bx,[16a6h]
  mov es:[095eh],bx
  mov bx,[16a4h]
  mov es:[0960h],bx
```

The menu variables are derived from the sound-device, CPU-speed, IRQ, and DMA
choices printed in the text setup screen. The demo does not integrate a custom
module replay inner loop in the visible code. It delegates module load and
playback to GoldPlay through far calls, then runs its own VGA timing around
that resident music path.

## Mode 13h And Frame Timing

Most graphics are simple chained mode `13h`: one byte per pixel, A000 memory,
320 bytes per row. The code waits for vertical retrace with the standard status
port `03dah` loop:

```asm
wait_retrace:
  mov dx,03dah
wait_set:
  in  al,dx
  test al,08h
  jz wait_set
wait_clear:
  in  al,dx
  test al,08h
  jnz wait_clear
  ret
```

This routine appears at `0x3babc` and is called constantly between palette
steps and moving-pixel passes.

The clear-screen helper at `0x3c0e5` writes A000 byte by byte until `DI`
reaches `0xfa00`:

```asm
es = a000h
di = 0
bl = 0
while di != fa00h:
  es:[di] = bl
  di++
```

The code uses `0xfa00` rather than a multiply or row count because `320 * 200`
is exactly 64000.

## Palette Engine

The working palette is a 768-byte table at `0x7d87`. Several helpers copy
source palettes into that table:

```text
0x3bf65  copy from 0x7787 to 0x7d87
0x3bf79  copy from 0x533e to 0x7d87
0x3bf8d  copy from 0x7487 to 0x7d87
0x3bfa1  copy from 0x7a87 to 0x7d87
0x3bfb5  copy from 0x6587 to 0x7d87
0x3bfc9  copy from 0x6887 to 0x7d87
```

The DAC uploader at `0x3bfdd` is deliberately simple:

```asm
cl = 0
bx = 7d87h
loop:
  out 03c8h,cl
  out 03c9h,[bx+0]
  out 03c9h,[bx+1]
  out 03c9h,[bx+2]
  bx += 3
  cl++
  cmp cl,0ffh
  jne loop
```

That writes DAC entries `0..254`. Other routines directly alter the last DAC
entry for flash effects, so the uploader stopping before index `255` is not a
problem in practice.

The fade-down helper at `0x3bfff` walks the palette bytes and decrements
nonzero components:

```asm
cx = 0300h
while cx:
  bx = 7d87h + cx
  al = [bx]
  if al > 0:
    [bx] = al - 1
  cx--
```

Two ramp helpers step the working palette toward target tables:

```text
0x3c029  compare against target table 0x6b87
0x3c04a  compare against target table 0x6e87
```

Their inner body is:

```asm
current = [7d87h + i]
target  = [target_table + i]
if current != target:
  current++
```

This only steps upward, so the source tables and call order matter. Darkening is
handled by `0x3bfff`, while these helpers push selected color components back
toward the next desired palette.

## First Bulk Image Copies

After entering graphics mode, the main script calls `0x3c070` four times:

```asm
si = 0000h, cx = 1388h, di = 579dh
si = 1388h, cx = 1388h, di = 5763h
si = 2710h, cx = 1388h, di = 56b3h
si = 3a98h, cx = 13e2h, di = 5655h
call 3c070h each time
```

`0x3c070` copies bytes from a relocation-marked data segment into A000:

```asm
es = a000h
ds = visual_data_segment
rep movsb
ds = local_data_segment
```

Then it spends two 64-frame phases on palette motion:

```asm
repeat 64:
  step palette toward target 0x6b87
  upload palette
  wait retrace

repeat 64:
  fade working palette down
  upload palette
  wait retrace
```

So these early calls are not only blits. They reveal or remove image chunks by
palette motion around the copy.

`0x3c0a2` is the full-screen sibling. It copies `0x7d00` words from a
relocation-marked source segment to A000, which is `64000` bytes:

```asm
si = 0000h
di = 0000h
cx = 7d00h
es = a000h
ds = source_segment
rep movsw
```

It then uses a target palette ramp, waits about 500 retraces, and fades the
palette down again.

## Coordinate Table For Moving Points

The coordinate effects use a compact table builder at `0x3aeea`. It creates 36
entries from two word tables:

```asm
[6458h] = 0
[645ch] = 0
while [6458h] <= 02cch:
  bx = [6458h]
  y = [6456h] + word [563eh + bx]
  x = [6454h] + word [590eh + bx]

  out_index = [645ch]
  [645fh + out_index] = x
  [64a7h + out_index] = y
  [64efh + out_index] = bx
  [6537h + out_index] = bx

  [645ch] += 2
  [6458h] += 14h
```

The stride `14h` and limit `02cch` give 36 points. Later routines keep both
current and alternate source indices so the effect can pair one point set
against another during morphs or mirrored motions.

The single-pixel plotter at `0x3b53a` is the core draw primitive:

```asm
di = [6450h] * 320 + [644eh]
es = a000h
al = [645eh]
es:[di] = al
```

Many routines build a 36-entry coordinate list, plot each point with color
`ffh`, wait one retrace, then plot the same points with color `00h` to erase
them. That is the recurring shape in `0x3af65`, `0x3b006`, `0x3b0a7`,
`0x3b150`, `0x3b1f0`, `0x3b290`, and `0x3b32e`.

The variants differ in how they combine the source tables:

- direct x/y pairing from `0x563e` and `0x590e`;
- swapped x/y pairing;
- scaled x/y using `mul` and `div` by `100`;
- pairing against tables at `0x5bde` and `0x617e`;
- adding the external motion offsets `[6454]` and `[6456]`.

The multiply/divide helpers are small and 286-friendly:

```asm
ax = source_value
cx = scale_word
mul cx
cx = 0064h
div cx
```

The visual result is a set of point paths that can expand, contract, swap axes,
or morph between coordinate tables without any per-point trigonometry.

## Sixteen By Sixteen Sprite Stamp

The stamp routine at `0x3b4b1` draws a 16x16 block:

```asm
di = [6450h] * 320 + [644eh]
bx = [0d0eh]
es = a000h
si = 010eh + bx
rows = 16
while rows:
  cx = 8
  rep movsw          ; 16 bytes
  di += 0130h        ; 320 - 16
  rows--
```

`0x3b4e1` is the same rectangle copy but from a fixed source area at
`010eh + 0b00h`, likely a blank or restore stamp.

`0x3b41a` drives this stamp over the 36-point coordinate table. It updates two
source indices, computes screen x/y, calls the stamp routine, and subtracts
`0100h` from `[0d0eh]` per step. That selects a different 16x16 source block for
successive stamps:

```asm
[0d0eh] = 0b00h
for each point-pair entry:
  compute x/y from coordinate tables and offsets
  draw 16x16 stamp from 010eh + [0d0eh]
  [0d0eh] -= 0100h
```

It is a simple data-driven sprite path. The expensive work is table lookup and
one multiply for `y * 320`; the pixel body is a straight `rep movsw` rectangle.

## Sparkle Pixels

`0x3be7e` updates 96 independent pixel offsets. Two word tables are involved:

```text
0x51bc  current pixel offsets
0x527c  step/color words
```

The inner body:

```asm
for i in 0..95:
  dx = current_offset[i]
  ax = step_word[i]
  [645eh] = al
  dx += ax
  if dx >= fa00h:
    dx = 0
  current_offset[i] = dx

  di = dx
  al = a000:[di]
  if al == 0:
    a000:[di] = 0feh - [645eh] + 1
```

The matching cleanup routine at `0x3bed7` erases only high-valued sparkle
pixels:

```asm
for i in 0..95:
  di = current_offset[i]
  if a000:[di] >= fah:
    a000:[di] = 0
```

That threshold makes the sparkle layer coexist with image pixels. It only
clears the temporary bright markers, not arbitrary art underneath.

`0x3bf08` is a related variant that advances each offset by its step and by one
full scanline:

```asm
dx += step_word[i]
dx += 0140h
if dx >= fa00h:
  dx = fa00h
```

The main script calls these routines around palette changes and retrace waits,
which makes the pixel layer appear to ride over the picture rather than being a
separate full-screen effect.

## Large Text And Band Scroller

The code has two text paths. The static credit text in the expanded image is
used as data, while `0x3c0fa` implements a moving 16-line band.

The band routine reads characters from a string pointer based on `[51a5h]`:

```asm
bx = 1b1ch + [51a5h]
ax = [bx]
if al == 0:
  [1ba2h] = 1
  return
if al == ' ':
  ax = 005bh
glyph = 1ba3h + (ax - 'A') * 0200h
```

It then modulates CRTC register `09h` through `0x3c1ec`:

```asm
out 03d4h,09h
out 03d5h,[1b9dh]
```

CRTC register `09h` is the maximum scanline register. Changing it while feeding
a 16-line band creates a vertical stretch/squash feel without copying a larger
font.

The hot scroller copy is at `0x3c1c7`:

```asm
es = a000h
ds = a000h
si = 0002h
di = 0000h
cx = 1400h
rep movsb
wait retrace
ds = local_data_segment
```

That shifts the first 16 display rows left by two bytes. The band routine then
clears the first two byte columns in those rows and emits two right-edge
columns at `x=318` and `x=319`:

```asm
for row in 0..15:
  a000:[row * 320 + 318] = glyph_column[row]
for row in 0..15:
  a000:[row * 320 + 319] = glyph_column[row]
```

The surrounding loop repeats this 32 times per character. This is not a normal
font blit. It is a byte-band shifter with CRTC stretch changes, designed for
motion and timing rather than text clarity.

## BIP4FUT.001 Tile Reveal

The strongest file-driven part is the reader at `0x3c260`. The main script
opens `BIP4FUT.001` and calls this routine four times:

```asm
mov dx,0000h        ; "BIP4FUT.001"
mov ah,3dh
int 21h
...
call 3c260h
call 3c260h
call 3c260h
call 3c260h
```

Each call reads one complete 320x200 frame:

```asm
ds = file_buffer_segment
dx = 0000h
cx = fa00h
ah = 3fh
int 21h
```

Then it reveals eight 80x100 tiles from that frame into the same centered
screen rectangle. The destination pointer is always `0x3ef8`:

```text
0x3ef8 = 50 * 320 + 120
```

So the tile appears at x=120, y=50. The inner tile copy is:

```asm
si = tile_source_offset
di = 3ef8h
rows = 100
while rows:
  cx = 0028h
  rep movsw          ; 40 words = 80 bytes
  di += 00f0h        ; 320 - 80
  si += 00f0h        ; 320 - 80
  rows--
```

The eight source offsets are:

```text
0000h   x=0,   y=0
0050h   x=80,  y=0
00a0h   x=160, y=0
00f0h   x=240, y=0
7d00h   x=0,   y=100
7d50h   x=80,  y=100
7da0h   x=160, y=100
7df0h   x=240, y=100
```

That divides each full 320x200 frame into eight 80x100 tiles: four across the
top half, four across the bottom half. Since `BIP4FUT.001` contains four
full-size frames, the routine displays 32 tile states total.

After several tile copies it calls:

```asm
repeat 8:
  wait retrace
```

The result is not a simple picture load. The file is a four-frame store, and
the runtime turns it into a 32-step centered tile/morph reveal without needing
to keep all frames in conventional memory at once.

## Why It Is Interesting

`Bip 4 the Future` is not as polished as the best-known 1993 PC demos, but it
is technically valuable because it shows a very practical first-generation
assembler trackdemo design:

- a custom EXE packer with LZ matches, segment normalization, and relocation
  replay;
- a plain mode-13h renderer built around A000 and DAC timing;
- GoldPlay integration through a resident far-call interface;
- palette table motion used as an effect layer;
- 36-point coordinate effects driven by precomputed tables, not live trig;
- 16x16 stamps with a branchless `rep movsw` pixel body;
- sparkle pixels that clean only their own high color range;
- a 16-line byte-band scroller with CRTC scanline modulation;
- a streamed raw-frame tile reveal from `BIP4FUT.001`.

The code is very direct. It often repeats similar routines instead of building
one generalized effect engine, but that is also what makes the inner loops easy
to trust: compute a small table, wait for retrace, write A000, step the palette,
repeat.
