Analysis model: gpt-5.5 xhigh, sol high

Last edited: 2026-08-26

# The EGA Sinusscroller by Official Version - Technical Dissection

Official Version's April 1991 `The EGA Sinusscroller` is a compact MS-DOS
demo whose title undersells the mechanism. A red 640-pixel, 16-scanline sinus
scroller runs from a 72.83 Hz interrupt while the foreground independently
maintains two XOR line fans. Each fan is a 40-segment moving history, not one
line redrawn at changing coordinates.

The surviving executable uses an unidentified `-OV-` LZ-style packer around a
Turbo Pascal program. One UNP pass restores the relocation-bearing image,
exposing the custom EGA scroller, timer shim, CRTC split, four-coordinate line
walker, and BGI setup around them.

![The EGA Sinusscroller direct main-screen runtime](images/ega-sinusscroller-official-version-runtime-main.gif)

This continuous silent direct-runtime excerpt begins at capture stream time
00:58. It shows the exact screen analyzed below: the fixed black Official
Version logo, red interrupt-driven scroller, and separate blue and green
40-line XOR histories. It is not one of the later distributor text files in
the ZIP.

Release year: 1991

## Identity, Date, And Archive Boundary

- Demozoo production page:
  https://demozoo.org/productions/356778/
- Pouet production page:
  https://www.pouet.net/prod.php?which=90316
- Preserved Scene.org release ZIP:
  https://files.scene.org/get/demos/groups/official_version/ovdemo.zip

Demozoo identifies the production as an MS-DOS demo by Official Version,
released in April 1991. The program repeatedly prints `Coded by Tasmaniac`,
and its own scroll text calls Tasmaniac the programmer. Demozoo's credit table
is empty, so that internal self-credit is the stronger attribution.

The release ZIP is 38,371 bytes:

```text
45817322bf0a671e7acb9c369ec85c876a839ae3bbb1a62bccc7d1f93610eb97  ovdemo.zip

OVDEMO.EXE   34,403 bytes  1991-04-26 15:39:10
BANNER.TXT      953 bytes  1991-07-12 20:30
TYPE_ME.NOW   3,015 bytes  1991-07-12 21:55
```

The April executable timestamp agrees with Demozoo's month. The two July
text files are later Cascada/Sound & Vision distribution additions. Neither
is opened by `OVDEMO.EXE`, and neither supplies graphics to the demo.

```text
406f344ffb886f13ee60cab5d8e81aef00e849a35a2862261b840fbb44279135  OVDEMO.EXE
9fc4e482b8d7770ce59bab65f0f562a2a5fb02c69f7f5cd17be5c281054a0727  BANNER.TXT
c3c12d0975a939a0e48c2070d495825a623004f76d4acf9fb27e3828a7dc5316  TYPE_ME.NOW
```

The scroll calls this the first non-commercial demo to use EGA high
resolution. That is an author claim, not a verified historical first. The
binary does prove that this production uses 640x350 EGA directly.

## Packed And Restored Executable

The original file is a valid 34,403-byte MZ with a 32-byte header, no
relocations, entry point `083C:000E`, and stack `0D22:0080`. Its entry maps to
file offset `83EEh`, only 629 bytes before EOF, and the tail contains the
`*FAB*` marker. That late-entry shape is the packed carrier, not the final
program architecture.

Running UNP once under DOS produced:

```text
restored size            53,984 bytes
declared MZ size         53,984 bytes
header                    1,120 bytes
relocations                 272
entry                    0000:0242
entry file offset          06A2h
stack                    0D7C:18F0
SHA-256  a428c30ea6cfd4ae6e6ac82b8e4fde018a9529442ec7e98c850163a6f4323fe5
```

All code offsets below refer to this restored image as `segment:offset`.
For segment-zero code, the corresponding restored file offset is
`0460h + offset`.

The restored image links Borland's Graph unit, the `EGAVGA` BGI driver, the
Triplex stroke font, floating-point support, CRT keyboard routines, and two
small custom units. This is why flat disassembly of the whole load image is
misleading: font and driver records sit beside executable code. Runtime `DS`
is the load segment plus `0C9Dh`, established at `0B2C:0000`.

The packed stub is still technically informative. Its `083C:000E..002A`
entry moves a `283h`-byte unpacker upward by `4BD0h` bytes and transfers to the
moved copy. Offsets `0066h..00F4h` decode literals and back-references;
`0104h..0155h` rebuild the 272 relocations, restores `SS:SP = 0D7C:18F0`, and
transfers to the original `0000:0242`. The visible `-OV-` marker does not
identify a standard EXEPACK or LZEXE variant, so a more specific packer name
would be guesswork.

## Exact EGA Mode

`InitGraph` at `0000:03A1` receives driver 3 and mode 1, Borland's EGA/EGAHi
pair. The live embedded EGAVGA 2.00 driver is at `0928:0000`; its EGAHi branch
sets maximum y to 349 and invokes BIOS mode `10h`. The resulting layout is
unambiguously planar 640x350x16 at `A000:`, with 80 bytes per scanline in each
plane. The linked Triplex font at `0407:0000` is also registered and used for
the large fixed captions.

## Runtime Route And Controls

The executable requires EGA or VGA and opens Borland's 640x350 16-colour EGA
mode. Its visible route is:

```text
black "Presenting" / giant Official Version title
blue 640x350 giant-letter wait message
white Official Version logo and "Presents" card
white main screen with logo, scroller, and two line fans
```

The main screen begins between capture stream times 00:45 and 00:50. The
foreground loop at `0000:069C` updates the two fans, polls scroller completion,
then checks the keyboard. Space (`20h`) is the manual exit key; Escape is not.
The scroller's `@` control byte increments a completion counter, and the main
loop also exits when that counter reaches one. The long text therefore ends
the demo naturally at its first terminal marker.

The cleanup at `0000:06C7` restores the old custom interrupt, the old timer
vector/PIT state, and the previous graphics mode before printing its closing
text. This is an ordinary return path, not a reset-only demo.

## The Giant-Letter Prelude Is A Character-Byte Shift

Before the BGI main screen, `0000:2278` animates the large letters on the blue
screen through `B800:` text memory. It waits for display-status bit 3 at
`03DAh` to leave and then enter vertical retrace. Across text rows 5..20 it
copies 79 character bytes while stepping over the untouched attribute bytes,
then injects one new character byte at column 79.

Per refresh this is 16 * 79 = 1,264 character-byte reads and 1,280 writes. The
custom 16-row font is at `0000:07D5`; the two messages contain 334 and 2,216
glyph columns and require 421 and 2,675 retrace frames respectively. This is a
separate opening mechanism, not the planar red scroller documented below.

## Three Schedulers Share The Screen

The main effect is deliberately split three ways:

```text
foreground as fast as BGI/EGA line drawing permits
  update blue 40-line history
  update green 40-line history
  poll completion and Space

IRQ0 at 72.83 Hz
  invoke INT 50h
    advance one scroller column
    shift 16 x 640 bits
    place the 16-row band through a sine table
  chain the original BIOS timer every fourth IRQ

INT 1Ch at the preserved 18.21 Hz BIOS rate
  move the EGA line-compare split by one scanline
  pause at the disabled-split endpoint, then reverse
```

This separation explains why the line fans, red text, and occasional repeated
screen region do not share a fixed phase. The fan renderer disables interrupts
only around each XOR line call, because both it and the scroller touch EGA
Graphics Controller state. It re-enables IRQs before coordinate and history
bookkeeping.

## The PIT Shim Preserves The BIOS Clock

The timer unit at `0B1C:006F` installs its own INT 08h and an INT 50h service
point. It programs PIT channel 0 through ports `43h/40h`:

```asm
mov al,34h              ; channel 0, lobyte/hibyte, mode 2
out 43h,al
mov al,00h
out 40h,al
mov al,40h
out 40h,al              ; divisor 4000h = 16,384
```

With the PC timer input of 1,193,182 Hz, the custom IRQ rate is:

```text
1,193,182 / 16,384 = 72.8265 Hz
```

INT 08h at `0B1C:0045` invokes INT 50h on each tick. Its byte at `CS:0044`
starts as `11h` and is rotated left once per IRQ. Carry occurs every fourth
rotation, at which point the handler chains the old INT 08h. The BIOS clock
therefore continues at `72.8265 / 4 = 18.2066 Hz`, effectively its normal
rate. On the other three ticks the handler sends the PIC end-of-interrupt
command `20h` to port `20h` itself.

Main calls `0A78:0017` to point INT 50h at `0A78:07A4`. Cleanup calls
`0A78:0000` to restore the prior vector. This timer and vector pairing is the
actual scroller scheduler.

## The INT 1Ch CRTC Split Sweep

Main also installs a handler for INT 1Ch at `0000:0000`. The segment word in
the call at `0000:0693` has an MZ relocation, so the pointer is relative to the
program's load segment; it is not the null pointer `0000:0000` in absolute
memory.

The handler advances `DS:06C2` through 0..350 once per preserved BIOS tick.
One direction increments modulo 351; the other adds 350 modulo 351, equivalent
to decrementing. At endpoint 350 a nine-bit counter at `DS:001C` holds the
state for 512 BIOS ticks, approximately 28.12 seconds, before reversing.

The helper at `02ED:00AD` reads the colour CRTC base from BIOS data
`0040:0063`, normally `03D4h`, and waits on vertical retrace at base+6,
normally `03DAh`. It writes the low eight line-compare bits to CRTC register
`18h` and bit eight through register `07h`, bit 4. Input 350 is translated to
line compare `1FFh`, effectively disabling the split. Cleanup explicitly sets
that value again.

This is the mechanism behind runtime frames where the top of the logo screen
restarts partway down the display. Those frames are valid demo output, not
ZMBV tearing or a bad screenshot. The clean 00:58 reference happens to show
the unsplit composition.

## A 640-Pixel Scroller In Sixteen Backward Rows

The main program builds 400 one-byte vertical positions at `DS:04BE`, then
passes that table to `0A78:0952`. The setup copies those bytes in reverse into
the scroller unit's `CS:058B..071A`, stores 400 as the wrap index, and starts
the phase counter at the same value. Index zero is not part of the active
cycle. The floating-point loop at `0000:056E..05E5` is exactly:

```text
table[i] = round(sin(i * pi / 200) * 50 + 100), i = 1..400
```

The Turbo Pascal six-byte Real constants decode to 200, pi, 50, and 100. The
table spans 50..150, adjacent entries differ only by -1, 0, or +1, and one
400-tick vertical period lasts approximately 5.493 seconds.

Other setup calls establish:

```text
glyph pointer table      0000:2356
scroll text              0000:143D
character gap            3 interrupt ticks
glyph height             16 rows
row width                40 words = 80 bytes = 640 pixels
EGA destination base     0000h within A000h
```

The INT 50h handler first deals with text at `0A78:07B3..0820`. A printable
byte is converted with `(character - 20h) * 2` into a word-sized glyph pointer.
The glyph begins with a column count followed by one 16-bit vertical mask per
column. `@` is a control byte: the handler skips it and increments the
completion count returned by `0A78:08E4`.

One interrupt consumes one 16-bit glyph column in `BX`. It then scrolls a
1,280-byte work area as sixteen independent 640-bit rows:

```asm
mov bp,16
mov di,0580h
mov si,di
std

row:
    mov cx,40
    shl bx,1            ; next glyph-column bit enters Carry
word:
    lodsw               ; walk right-to-left
    rcl ah,1
    rcl al,1            ; shift this 16-bit piece through Carry
    stosw
    loop word
    dec bp
    jnz row
cld
```

The reversed traversal propagates the carry across all 40 words without a
separate edge buffer. Repeating it sixteen times distributes the sixteen bits
of the current glyph column to the sixteen raster rows. At 72.83 interrupts
per second, the text advances one pixel per interrupt while the three-tick gap
between characters contributes three blank columns.

## Sine Placement And The EGA Band Copy

After decrementing and wrapping the 1..400 phase, the handler reads one byte
from the reversed sine table. With `height = 16`, it computes:

```text
first destination scanline = sine[phase] + 2*height
byte offset                = 80 * first scanline
```

The multiply is explicit: `4*x + x`, followed by four left shifts, gives
`80*x`. The blitter at `0A78:0847..08D9` selects Graphics Controller register
5 value `08h` and Sequencer map mask `08h`, copies 80 bytes for each of the 16
rows, and steps the destination upward by 80 bytes after each row. It clears
one 80-byte scanline immediately below and one immediately above the moving
band, so old red pixels do not leave a full-screen trail. Since the sine range
is 50..150, the first copied row lies at y=82..182 and the complete 16-row band
occupies scanlines 67..182. Each tick writes exactly 1,440 bytes to `A000:`:
1,280 copied bytes plus two 80-byte clears.

Normalized, the hot path is:

```text
phase = phase - 1
if phase == 0: phase = 400
y = sine[phase] + 32

clear(A000:(y + 1) * 80, 80)
for row in 0..15:
    copy_80_bytes(backward_row_buffer[row], A000:(y - row) * 80)
clear(A000:(y - 16) * 80, 80)
```

The underlying black logo and BGI text are not repainted by this path because
the custom copy changes only the scroller's selected plane and narrow moving
scanline band. The separate CRTC line compare can alter how that prepared
screen is scanned out. The red text itself is not a BGI string drawn at new
coordinates each frame.

The first `@` lies after 3,610 characters. Their glyph widths total 42,152
columns; adding three loading/gap ticks per character and the initial three
ticks gives 52,985 PIT ticks. Nominal automatic completion is therefore
727.56 seconds, about 12 minutes 7.6 seconds. This explains why the 140-second
diagnostic run remained in the main scroll.

## The Two 40-Segment Fan Histories

The foreground calls `02FE:0118` twice per pass, first with true and then with
false. The flag selects state block `DS:06CA` with EGA colour 2 or state block
`DS:081E` with colour 4. Each block has:

```text
+00,+02,+04,+06  four current line-coordinate words
+08              history slot, 1..40
+0A              velocity lifetime countdown
+0C..+12         four signed velocity words
+14              first of 40 history records

history record:  4 words / 8 bytes
history size:    40 * 8 = 320 bytes per fan
```

The unit initializer at `02FE:0494` fills all 40 records for both fans from
the centre constants 319 and 174, initializes each current state, and sets
both ring indexes to one. That prevents uninitialized EGA memory from being
XORed during the first 40 replacement passes.

Each update selects `base + 12 + 8*slot`, disables interrupts, and draws that
stored segment once. In XOR mode this erases the oldest visible line. If the
velocity countdown is zero, each velocity becomes:

```text
Random(15) - 7       ; exact range -7..+7
```

The static word used for the range is 14 at `DS:021E`; the code calls
`Random(value + 1)` and subtracts `value / 2`. It rejects an all-zero pair for
each endpoint and chooses a lifetime of `(Random(4) + 1) * 100`, or 100, 200,
300, or 400 foreground updates.

The four coordinate helpers add signed velocity and test a boundary. If the
candidate is outside, they keep the previous coordinate for that pass and
negate the velocity, producing a one-pass pause at the reflection. The binary
has a striking asymmetric pairing: offsets `+00` and `+02` use the 1..639
helper, while `+04` and `+06` use the 1..349 helper. The line routine consumes
the four words in its own endpoint order. This is why the fans can spend time
partly outside the visible 640x350 area instead of behaving like two neatly
clipped screen-space segments.

After the moves, the updater disables interrupts again, draws the new segment,
stores its four coordinates into the selected history record, advances the
slot with a 40-to-1 wrap, and decrements the velocity lifetime. The visible fan
is consequently exactly the newest 40 segments for that state block.

```text
old = history[slot]
xor_line(old, colour)       # remove

if lifetime == 0:
    velocities = nonzero random values in -7..+7
    lifetime = 100 * (Random(4) + 1)

reflect_and_move(four coordinates)
xor_line(current, colour)   # add
history[slot] = current
slot = slot % 40 + 1
lifetime--
```

## The EGA XOR Line Walker

The fan call reaches the custom rasterizer at `05CC:02A5`, not Borland's
generic high-level `Line` wrapper. It programs the Graphics Controller:

```asm
GC index 0 = colour        ; Set/Reset
GC index 1 = 0Fh           ; enable Set/Reset on all four planes
GC index 3 = 18h           ; XOR logical operation, rotate zero
GC index 8 = changing mask ; one pixel bit in the target byte
```

The walker at `05CC:00C7..02A2` is an all-octant integer line routine. It
normalizes endpoint direction, computes `dx`, `dy`, signs the 80-byte row
stride, and dispatches to x-major or y-major loops. Pixel addressing is the
canonical EGA high-resolution form:

```text
offset = 80*y + floor(x/8)
mask   = 80h >> (x & 7)
```

Horizontal lines have a specialized first-byte/middle-byte/last-byte path;
vertical lines repeatedly add `+80` or `-80`. General lines keep doubled error
increments in `DS:09AA` and `DS:09AC`. The x-major loop rotates the one-bit
mask and carries into the next byte; the y-major loop advances by the signed
row stride every pixel and conditionally rotates/advances x. Every pixel uses
an EGA latch-triggering read-modify-write, so the selected colour is XORed into
the enabled planes.

This closes the complete fan path: ring selection, old-line removal, random
velocity schedule, boundary reflection, Bresenham-class rasterization, new-line
insertion, history replacement, and interrupt-safe hand-off to the scroller.

## Runtime Capture

The direct run used DOSBox-X 2024.03.01 with `machine=ega`, fixed 12,000
cycles, dummy host audio, and normal visual output redirected away from the
console. DOSBox-X recorded a silent 640x350 ZMBV stream at 59.701656 fps. The
diagnostic run lasted 140.280866 seconds and remained in the long main scroll;
the process was stopped after sufficient visual coverage rather than being
presented as a natural demo exit.

The public GIF is a continuous 8-second excerpt from 00:58 at 12 fps. It keeps
the native 640x350 canvas and shows no contact sheet, unrelated executable, or
reconstructed effect. No demo audio was enabled, monitored, or published.

![The EGA Sinusscroller direct reference frame](images/ega-sinusscroller-official-version-runtime-main.png)

This direct frame at 00:58 is useful as a static concordance: black fixed BGI
art, red interrupt scroller, blue colour-2 fan, and green colour-4 fan are all
visible in the same exact runtime state.

## No Live Audio Path

The linked CRT unit contains ordinary PC-speaker `Sound` and `NoSound`
helpers using ports `61h`, `43h`, and `42h`, but main has no reachable calls to
them. No production path accesses AdLib/OPL ports. PIT channel 0 is used for
the animation scheduler, not sound. The demo is therefore silent by code as
well as by capture policy.

## What The Demo Actually Spends Time On

The title suggests one sinus calculation per frame, but the hot work is more
specific:

- 72.83 times per second, sixteen 40-word rows are shifted through carry:
  640 word updates per scroller tick;
- the scroller then copies 16 * 80 = 1,280 bytes to EGA and clears 160 boundary
  bytes;
- every foreground pass XOR-rasterizes four segments total: old and new for
  each of two fans;
- only two of those four segments remain as new visible history, while the
  other two remove the ring entries they replace;
- the fixed logo and captions are setup cost and are not repainted each pass.

That division of labour is the central design: a deterministic timer-driven
bitstream for the text, paired with CPU-speed-dependent XOR histories whose
line cost varies with segment length and slope.

## Bottom Line

`The EGA Sinusscroller` is a small but unusually transparent early-PC demo.
Its restored binary shows a careful BIOS-clock-preserving PIT shim, a genuine
640-bit carry scroller, narrow planar cleanup, two 40-entry XOR history rings,
and a complete all-octant EGA line walker. The uneven coordinate-bound pairing
also preserves some of the one-day-demo roughness admitted by its own text.

The direct pictures now match that mechanism exactly: they show the main OV
logo screen whose interrupt and foreground loops are documented here.
