Analysis model: gpt-5.5 xhigh, sol high

Last edited: 2026-08-25

# Atom by Sorcerers - Technical Dissection

Release year: 1990

## Scope

This covers `Atom` by Sorcerers, released in October 1990 for MS-DOS. Pouet
lists it as a 32K intro, coded by Fox of Sorcerers. The production is small and
very early, but technically memorable because it plays a digitized one-bit vocal
sample through the PC speaker while a text-mode intro keeps running.

Sources and artifact:

- [Pouet production page](https://www.pouet.net/prod.php?which=4066)
- [Hornet archive mirror](https://files.scene.org/get/mirrors/hornet/demos/1990/atom.zip)

Hashes from the examined archive:

```text
2f9de314e168e9dcd6203c6df9822d0731e605863cf39a9147d13eaba437e161  atom.zip
2472d472395c22eb880a945d57085a60f411b019ef33ffe83ba9f0770f48a024  atom.exe
0d74d6ea390c8ca8fcf1d8f510baf6c95506badffc2895483ecfbd5a1f772d0b  exact 22,816-byte MZ load image
```

The executable contains an old BBS contact line. I do not reproduce that
personal contact detail here.

## Keyed Runtime Run

`Atom` is not a game like Sorcerers'
[Nope](nope-sorcerers-analysis.html), but it is interactive. Its own scroller
asks the viewer to press letter keys, says that `S` toggles sound, and
names `Esc` as the exit key. A passive loop was therefore not enough to verify
the released program.

The retained keyed capture was made under DOSBox-X 2026.01.02. Its input
schedule records `A`, `M`, `Z`, and `S` five seconds apart. The visual geometry
changes after each scheduled input, but Atom does not print the key onscreen;
the input identities therefore come from the capture schedule and code
concordance, not from the pixels alone. An operator note reports a later `Esc`
and DOS return, but the retained 34-second source still ends on the effect. I do
not treat that return as captured visual evidence.

| Input | What happened in the run |
| --- | --- |
| no input | The initial mirrored trails, edge marks, and three text streams started. |
| `A` | The first scheduled parameter change begins; the rolling history converges on a new scale/phase path while the streams keep moving. |
| `M` | A second scheduled geometry change begins five seconds later. |
| `Z` | A third visibly different path begins after the next scheduled key. |
| `S` | A fourth path change is visible. The sample-feed toggle is established by code, not by these silent pixels. |
| `Esc` | Not shown in the retained capture; static code selects the staged shutdown described below. |

The continuous GIF is an 18-second, 216-frame excerpt matching source time
`12.500..30.500`. Scheduled `A`, `M`, `Z`, and `S` inputs fall at GIF times
about `0.5`, `5.5`, `10.5`, and `15.5` seconds. It is an uncropped 720x400
capture of the complete guest text raster, but a white outlined host mouse
cursor remains near the center and is not an Atom graphic:

![Uncropped Atom keyed capture with mirrored CP437 trails, edge marks, text streams, and a host cursor overlay](images/atom-runtime-symmetric-dots.gif?v=innerloop-20260825)

This editorial four-panel sheet samples the same source after the scheduled
keys and adds the labels `after A/M/Z/S`; those labels are not guest pixels.
Each panel retains the same host cursor. It is useful because the bilateral
`F9h` trails, edge marks, and text belong to the loop dissected below, but it is
a diagnostic timeline rather than a continuous native frame.

![Editorial Atom four-panel keyed-state sheet with added labels and retained host cursor](images/atom-runtime-timeline.png?v=innerloop-20260825)

The source was captured through X11 with no audio output. DOSBox-X used
the normal CPU core at a fixed 8,000 cycles, 16 MB of memory,
`machine=svga_s3`, no aspect correction or scaler, disabled guest sound
devices, and a dummy host audio driver. The public GIF ends before the old BBS
contact line in the embedded text can appear. The published runtime evidence is
the silent GIF and still above; there is no retained or published Atom MP4.

## Runtime-To-Code Concordance

The key branch begins at `0739h`. After reading and uppercasing a key, the code
uses its value modulo 32 plus 30 as a path-scale parameter (`0754h..0764h`). It
also samples `[029Ch]` to choose two small phase divisors (`0768h..078Bh`). That
is why `A`, `M`, and `Z` immediately produce different paths in the keyed run.

`S` has an extra branch at `078Fh..07B5h`: it flips the program's sample-feed
flag and moves the sample-buffer rewrite cursor 100 bytes ahead of the current
sample position. The key set at `CS:03EFh` contains two values, Ctrl-C (`03h`)
and Esc (`1Bh`); either selects shutdown at `07B9h..07C8h`. The retained pixels
exercise the scheduled ordinary-letter and `S` geometry changes. Shutdown is
established by static control flow, not by the retained final frame.

The guest timer handler at `CS:4763h` writes sample progress to `DS:[029Ch]`.
The main loop begins at `CS:0663h` and calls the shared stream updater at
`CS:0280h` from `0811h`, `0826h`, and `0874h`. Those instances use the embedded
streams at `CS:3869h`, `CS:41AFh`, and `CS:436Eh`, accounting for the three
moving text lanes.

All visible marks converge on the direct text-cell writer at `4574h`:

| Captured feature | Main-loop code | Writer input |
| --- | --- | --- |
| top/bottom moving marks | `CS:0970h..09D6h` | character `2Dh` (`-`) at mirrored rows |
| left/right moving marks | `CS:0A0Ah..0A70h` | character `7Ch` at mirrored columns |
| paired curved trails | `CS:0A70h..0BF4h` | CP437 character `F9h` at center plus/minus sine coordinates |
| old-trail erasure | `CS:0BF7h..0C5Ch` | character `20h`, attribute `00h`, at the oldest paired positions |

Helpers `CS:45BFh` and `CS:45D2h` feed a common scaled lookup at `CS:45A0h`;
the second helper advances the table phase by one quarter period before
wrapping. The loop uses a 32-slot coordinate ring but erases the slot one ahead
of the insertion slot, leaving 31 mirrored point pairs in steady state. This is
the bilateral dotted path visible in every keyed frame, not a framebuffer line
or sprite renderer.

With host speaker output disabled, the guest ISR still updated `[029Ch]`, so
the streams and point paths continued. That establishes the visual timing path
only; the run did not evaluate the sample's sound.

## Executable Shape

`atom.exe` is a normal MZ executable, not LZEXE/PKLITE-packed.

```text
physical file size: 23,552 bytes
declared MZ size:   23,072 bytes
header size:           256 bytes
loaded image:       22,816 bytes
relocations:            56
entry point:        CS:IP 0000:0CE8
stack:              SS:SP 05B7:4000
tail after MZ:         480 bytes, all zero padding in this copy
```

The binary has Borland/Turbo Pascal-style runtime traces, including the
`Runtime error` string and far calls into runtime segments. The demo code is not
obfuscated. The main program starts at image offset `0CE8`, and the custom
hardware routines live mostly around `4574..4862`.

There are two address spaces worth keeping distinct. The MZ entry has relative
`CS = 0000`, so `CS:xxxx` labels map directly to load-image offsets. Runtime
startup at `CS:48F0h` loads relocated segment `0568h` into `DS`; therefore a
`DS:xxxx` object occupies load-image offset `5680h + xxxx`. For example, the
sine table at `DS:0002h` is physically at load offset `5682h`, while the long
text at `CS:3869h` is physically at `3869h`. Bare bracketed globals in the
disassembly are `DS` references, not same-numbered load-image offsets.

## Startup And Text Mode Detection

The entry point first calls runtime startup, then sets up a small set of global
screen values from the BIOS Data Area:

```asm
00d02: mov ax,0040h
00d06: mov di,0049h
00d0a: cmp byte ptr es:[di],07h  ; current video mode
00d10: mov word ptr [0000],0b000h ; mono mode uses B000

00d16: mov ax,0040h
00d1a: mov di,004ah
00d1e: mov al,es:[di]
00d21: mov [0292h],al            ; text columns

00d24: mov ax,0040h
00d28: mov di,0084h
00d2c: mov al,es:[di]
00d31: inc ax
00d32: mov [0293h],al            ; text rows
```

The video base defaults to color text memory (`B800h`). If BIOS mode is 7, it
switches to mono text memory (`B000h`). It also reads the current column count
and row count, so it is not hard-coded to only 80x25. One embedded scroller
mentions trying larger modes such as 132x43, and the code shape backs that up.

Derived globals:

```text
[0292] columns
[0293] rows
[0294] columns / 2
[0295] rows / 2
[0298] columns * rows * 2, the byte size of the text screen
[0000] active text-memory segment, B800h or B000h
```

## Text Cell Writer

Most of the visible intro is built on a tiny direct text-mode writer at
`4574`. It computes a character-cell offset and writes the character/attribute
word directly to video memory:

```asm
4574: push bp
4575: mov  bp,sp
4577: mov  al,[bp+08h]       ; row-like coordinate
457c: mov  bl,[0292h]        ; columns
4580: xor  bh,bh
4582: mul  bx
4584: mov  bl,[bp+0ah]       ; column-like coordinate
4587: add  ax,bx
4589: dec  ax
458a: shl  ax,1
458c: mov  bx,ax
458e: mov  ax,[0000h]        ; B800/B000
4591: mov  es,ax
4593: mov  ah,[bp+04h]       ; attribute
4596: mov  al,[bp+06h]       ; character
4599: mov  es:[bx],ax
459d: ret  8
```

There is a second helper at `45F5` for filling character bytes while leaving
attributes untouched:

```asm
45f8: les di,[bp+08h]        ; far text pointer
45fb: mov al,[bp+04h]        ; character
45fe: mov cx,[bp+06h]        ; count
4601: stosb
4602: inc di                 ; skip attribute byte
4603: loop 4601h
```

Both coordinates are consumed through their low bytes. The subtraction makes
the column coordinate one-based, while the row is multiplied without a
decrement and is therefore zero-based. There is no bounds test: coordinates
outside the nominal column/row range are reduced modulo 256 and then simply
spill through the 16-bit linear cell-offset calculation. The normal sine
amplitudes remain inside the screen, but the edge formulas deliberately reach
zero and one-past-dimension values. There is also no backbuffer,
retrace wait, or page flip. Each store becomes visible whenever the text adapter
next scans that cell.

This is why the demo can do its simple but fast text effects without BIOS
screen output: the runtime only supplies setup and keyboard helpers; the effect
path writes text RAM directly.

## Embedded Text Streams

The program carries several text streams:

```text
3869h  long main scroller/greets/technical text
41AFh  upper scroller
436Eh  lower scroller
```

The parser at `CS:0144h` treats actual spaces, `#`, CR, and LF as separators.
It builds one Turbo-style length-prefixed token at a time; underscores inside a
token are converted to visible spaces. Encountering `#` resets the current far
pointer to that lane's base pointer, so all three scripts loop. The writeup
avoids reproducing the historical contact line present in the lower stream.

### Three Lane Records

Each lane occupies a 274-byte aligned stack slot: 273 meaningful bytes—a
256-byte token buffer followed by state at offsets `+100h..+110h`—and one
alignment byte before the next lane:

```text
+100  signed reveal position, or literal idle marker -999
+102  far script-base pointer
+106  far current-script pointer
+10A  32-bit next/update timestamp in sample-byte units
+10E  word update interval
+110  byte screen row
```

The three instances are initialized with intervals `80`, `35`, and `50`. Their
rows are `center_row`, `center_row/2`, and
`center_row + center_row/2`—12, 6, and 18 in the captured 80x25 mode. With the
normal 11,932 Hz one-bit IRQ and eight IRQs per data byte, those intervals are
about 53.6, 23.5, and 33.5 milliseconds. `CS:0280h` compares the wrapped current sample position
against each timestamp and repeatedly catches up if more than one interval has
elapsed; this is a sample-clocked scheduler, not one text step per host frame.

The character mover at `CS:0041h` starts a token at reveal position `17` and
decrements it on every lane tick. For each character `i = 1..length`, only
positions for which `1 <= reveal+i-1 <= 17` are written. The value also indexes
the attribute ramp at `DS:0202h`; all other token cells are replaced with a
space/attribute-zero cell. Normalized, its hot path is:

```c
left = center_column - token.length / 2 - 1;
for (i = 1; i <= token.length; ++i) {
    color_index = reveal + i - 1;
    if (1 <= color_index && color_index <= 17)
        cell(left + i, lane.row) = { token[i], attr[color_index] };
    else
        cell(left + i, lane.row) = { ' ', 0 };
}
if (--reveal < -token.length)
    reveal = -999;
```

Thus each phrase is stationary and a 17-cell colored reveal window travels
through it; this is not a conventional whole-line scroller. A token takes
`length + 18` lane ticks from its first one-character edge through final
erasure.

The upper and lower scripts are not permanently active. After updating the
main lane, `CS:0849h..0862h` searches its current token for `up here`, and
`CS:0897h..08B0h` similarly searches for `down here`. A match enables that side
lane. When its current pointer wraps back to its base pointer, the main loop
disables it and restores the lane's `-999` idle state. The captured center,
upper, and lower phrases therefore all come from these fixed-cell reveal loops.

The main setup allocates or receives a far buffer, then copies the embedded
sample data from `CS:0D71h` into that buffer:

```asm
00436: mov ax,2a94h          ; 10,900 bytes
0043a: call runtime_alloc
...
00449: push far sample_buffer
00454: push 0000:0d71h
0045f: call 4609h            ; read source byte
00463: call 461Bh            ; write byte to far buffer
00466: cmp [bp-0ch],2a94h
0046b: jne copy_loop
```

The embedded technical text says the sample is 10,900 bytes, and playback uses
length `2A94h`. The inclusive setup loop actually copies offsets `0..2A94h`,
10,901 bytes, into a nominally 10,900-byte allocation. The later live feed loop
has the same `> 2A94h` wrap test. The player prefetches that extra byte after
the last real output byte, then notices the end pointer on the following IRQ
and never sends the prefetched byte to the speaker. The one-byte overrun is
therefore both written and read, even though it is not audible output.

## One-Bit Sample Player

The heart of `Atom` is the PC speaker player at `46B1..4862`.

The later Pouet author comment says the digitized sound was the main point of
the intro and describes experiments with a one-bit sampler and a sped-up clock
interrupt. The binary confirms that design: it installs its own timer IRQ,
plays one bit per interrupt, and repairs the BIOS clock count when the sample
ends.

### Player State

The sound routine keeps its state in a compact table:

```text
01C4  original port 61h value with speaker bits cleared
01C5  port 61h value with bit 1 set
01C6  current sample byte pointer
01C8  sample start pointer
01CA  sample end pointer
01CC  bit index within current byte
01CD  zero-run countdown
01CE  current sample byte being shifted
01CF  player data segment
01D1  sample data segment
01D3  sample length
01D5  PIT divisor low byte
01D6  saved old INT 08h vector
029A  sound-finished flag in the main data segment
029C  sample progress counter visible to the main effect loop
```

The visible animation uses `[029C]` as a clock. The IRQ writes:

```asm
04777: mov ax,[01c6h]
0477a: sub ax,[01c8h]
0477e: mov es:[029ch],ax
```

That ties text movement and key-triggered effects to audio progress without
explicit synchronization code.

### Installing INT 08h

The install function receives the sample far pointer, sample length, and timer
divisor. For the normal playback call, the divisor is `0x64` and the length is
`0x2A94`.

It saves the old timer vector from the interrupt table, writes a new vector for
INT 08h, and reprograms PIT channel 0:

```asm
04731: push ds
04732: xor ax,ax
04734: mov ds,ax
04736: mov si,0020h           ; IVT entry for INT 08h
04739: lea di,[01d6h]
04741: movsw
04743: movsw                 ; save old vector

04745: xor ax,ax
04747: mov es,ax
04749: mov di,0020h
0474c: mov ax,00c3h
0474f: cli
04750: stosw                 ; new offset 00C3h in this segment
04751: mov ax,cs
04753: stosw                 ; new segment

04754: mov al,36h
04756: out 43h,al            ; PIT channel 0, mode 3
04758: mov al,[01d5h]        ; divisor low byte, normally 64h
0475b: out 40h,al
0475d: mov al,00h
0475f: out 40h,al            ; high byte zero
04761: sti
```

The effective IRQ rate for the normal call is:

```text
1,193,182 Hz / 100 = about 11,932 interrupts per second
```

That matches the embedded statement that the timer ticks about 12,000 times per
second. Since one bit is played per tick, one 8-bit sample byte lasts eight
interrupts.

The shipped stream makes the count slightly less obvious than `length * 8`.
Installer `471Fh` reads offset 0 and immediately increments the current pointer.
After that first byte's eight bits, `47C0h` increments the pointer again before
fetching, so offset 1 is skipped. The bytes actually sent are:

```text
offset 0, then offsets 2..2A93h
10,899 output bytes
87,192 bit-output IRQs
1 final end/restore IRQ
```

At the exact PIT input constant used here, the finished flag arrives after:

```text
87,193 * 100 / 1,193,182 = 7.307603 seconds
```

The production loops/restarts around that exact sample-sized timing unit in
the main visual scheduler. Progress still rises cleanly from 1 through 10,899
during output because it reports the pointer offset, hiding the skipped data
byte from the visual clock.

### Speaker Output Inner Loop

The IRQ entry saves registers, restores the player data segment, updates the
visible sample-position counter, and checks whether the stream has reached its
end:

```asm
04763: pushf
04764: push ax
04765: push bx
04766: push cx
04767: push dx
04768: push es
04769: push ds
0476a: push si
0476b: push di
0476c: push bp
0476d: mov ds,cs:[01cfh]

04777: mov ax,[01c6h]
0477a: sub ax,[01c8h]
0477e: mov es:[029ch],ax

04782: mov ax,[01c6h]
04785: cmp ax,[01cah]
04789: jae finished
```

The bit player uses the high bit of the current sample byte. If it is set, it
writes the saved "speaker high" port value. Otherwise it writes the saved
"speaker low" value:

```asm
0478f: test byte ptr [01ceh],80h
04794: je  low_bit

04796: mov al,[01c5h]
04799: out 61h,al
0479b: jmp shift

low_bit:
0479d: mov al,[01c4h]
047a0: out 61h,al

shift:
047a2: shl byte ptr [01ceh],1
047a6: inc byte ptr [01cch]
047aa: cmp byte ptr [01cch],07h
047af: jbe irq_exit
```

The loop plays bits most-significant first. After eight bits, it fetches the
next byte.

### Dormant Zero-Run Marker

After a byte is exhausted, the code handles a small control marker:

```asm
047b1: cmp byte ptr [01cdh],00h
047b6: je  fetch_next
047b8: dec byte ptr [01cdh]
047bc: xor al,al
047be: jmp set_current_byte

fetch_next:
047c0: inc word ptr [01c6h]
047c4: mov bx,[01c6h]
047c8: mov al,es:[bx]
047cb: cmp al,6fh
047cd: jne set_current_byte

047cf: inc bx
047d0: mov al,es:[bx]
047d3: dec al
047d5: mov [01cdh],al
047d8: inc word ptr [01c6h]
047dc: xor al,al

set_current_byte:
047de: mov [01ceh],al
047e1: mov byte ptr [01cch],00h
```

`0x6F` is a control byte. It is followed by a count byte. The player can emit
zero bytes for that count instead of reading more sample bytes. This is not a
general compressor, but it would be enough to collapse stretches of silence or
neutral output in a one-bit stream.

The distinction is conditional because this release never exercises it. An
exact scan of the 10,901 copied source bytes finds zero `6Fh` values, including
the overrun/prefetch byte. The normal sample, rolling source restore, rolling
zero feed, and all 41 shutdown slices therefore stay on the literal/zero paths;
the marker branch is implemented player capability, not part of Atom's shipped
sample encoding.

The normal IRQ exit sends End Of Interrupt to the PIC and restores registers:

```asm
047e8: mov al,20h
047ea: out 20h,al
...
047f6: iret
```

## End Of Sample And Clock Repair

When the sample pointer reaches the end, the ISR restores normal PIT channel 0
and reinstalls the old INT 08h vector:

```asm
047f7: cli
047f8: mov al,36h
047fa: out 43h,al
047fc: mov al,00h
047fe: out 40h,al
04800: mov al,00h
04802: out 40h,al             ; divisor 65536, normal BIOS timer

04804: xor ax,ax
04806: mov es,ax
04808: lds ax,cs:[01d6h]      ; old vector
0480e: mov di,0020h
04811: stosw
04812: mov ax,ds
04814: stosw
04815: sti
```

Then it compensates the BIOS time-of-day tick count at `0040:006C`. This is the
part the author later remembered: the interrupt rate is much faster than the
normal 18.2 Hz clock, so the demo has to repair time after playback.

```asm
04818: mov al,[01d5h]         ; divisor, normally 100
0481d: shl ax,1
0481f: shl ax,1
04821: shl ax,1               ; divisor * 8 bits per byte
04823: mov cx,[01d3h]         ; sample length, 10900
04827: mul cx                 ; DX:AX = divisor * 8 * length

0482a: mov ax,0040h
0482d: mov es,ax
0482f: mov bx,006ch
04833: add es:[bx],dx
04836: adc word ptr es:[bx+2],0
```

Why the high word works:

```text
elapsed BIOS ticks ~= (divisor * 8 * sample_length) / 65536
100 * 8 * 10900 = 8,720,000
8,720,000 / 65,536 = 133.05 BIOS ticks
133 / 18.2065 Hz = 7.3 seconds
```

The repair uses the nominal 10,900-byte length even though the player outputs
10,899 bytes. Both products have high word 133, so the one-byte skip does not
change the normal call's integer BIOS-tick correction. The low word is discarded
in either case.

The code also wraps against the 24-hour BIOS tick limit:

```asm
0483b: cmp word ptr es:[bx+2],0018h
04840: jb  ok
04844: cmp word ptr es:[bx],00b0h
04849: jb  ok
0484b: sub word ptr es:[bx],00b0h
04850: sbb word ptr es:[bx+2],0018h
```

Finally it sets `[029A] = 1`, jumps back to the common IRQ exit, and the main
loop can see that sound playback is done.

## Keyboard And Drive Light Effects

The intro text asks the viewer to watch the keyboard and disk drive. The code
does this directly:

```asm
008f0: mov ax,0040h
008f4: mov di,0017h
008f8: mov es:[di],dl         ; BIOS keyboard flag byte

0090c: mov dx,03f2h
0090f: out dx,al              ; floppy digital output register
```

The scheduler is exact rather than random. Its 21-byte boundary table at
`DS:0218h` is:

```text
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20,
22, 24, 26, 28, 32, 36, 38, 42, 43, 44
```

For event `i = 0..19`, the write fires while the rolling buffer-copy phase lies
between `table[i] * 247` and `table[i+1] * 247 - 2`. The strict second
comparison excludes `table[i+1] * 247 - 1`. The counter then advances
and wraps after event 19. The keyboard bytes at `DS:0214h` are exactly `20h,
40h, 10h, 40h`: Num Lock, Caps Lock, Scroll Lock, Caps Lock in the BIOS
keyboard-state byte. This writes software flags, not an `8042h` LED command.
The floppy control value is derived from the same event counter:

```asm
008fb: mov ax,[effect_counter]
008ff: and ax,0002h
00902: shr ax,1
00904: mov cx,0003h
00907: mul cx
00909: add ax,00fch
0090f: out dx,al
```

On exit it clears the keyboard flag byte and writes `0xFF` to `3F2h`:

```asm
00cd2: mov ax,0040h
00cd6: mov di,0017h
00cda: mov byte ptr es:[di],00h
00cde: mov al,0ffh
00ce0: mov dx,03f2h
00ce3: out dx,al
```

The DOR alternates `FCh` and `FFh`: all four motor bits and DMA/IRQ enable stay
set while the selected-drive bits change from zero to three. This is crude but
very much of its time: it treats the PC as a pile of visible hardware
registers, not only as a screen and speaker.

## Main Visual Loop

There is no video-frame boundary in `Atom`. `CS:0663h..0CB8h` is a busy main
loop whose visible work is gated by the asynchronously changing sample pointer
`DS:[029Ch]`. One traversal has this ownership order:

```text
sound-end/restart or shutdown-chunk state
rolling sample-buffer feed and keyboard-safe window
key decode and path-parameter update
three sample-clocked text reveal lanes
keyboard-state / floppy-DOR event scheduler
attribute phase
new edge marks, then old edge-cell erasure
new sine point, mirrored point draw, oldest mirrored-pair erasure
ring-index rotation and shutdown-complete test
```

That order matters. Everything writes the same text page directly. There is no
saved background beneath a dot or edge mark: edge cleanup writes a space with
attribute `07h`, while trail cleanup writes a space with attribute `00h`. If a
cleanup cell overlaps a phrase, it punches a temporary hole until the phrase's
own lane updater writes there again.

### Rolling Sample Feed And Input Window

Every busy-loop traversal writes one byte into the active far sample buffer.
When the feed flag is set, the source is `CS:0D71h + feed_phase`; when clear,
the byte is zero. The phase advances over inclusive offsets `0..2A94h` and then
wraps. `S` therefore does not merely flip the speaker latch: it changes whether
the main loop progressively restores the embedded stream or progressively
zeros the live playback buffer.

Keyboard polling is suppressed while that rolling write head is in the simple,
non-wrapping interval `[sample_progress, sample_progress + 100]`. Outside the
interval, `CS:0739h` checks and reads a key. This keeps key processing away from
the approximately next 100 buffer bytes being consumed, although the test does
not itself handle a circular interval crossing `2A94h`.

### Key-Derived Geometry

Every accepted key is uppercased and updates all three path parameters:

```c
path_scale = (uppercase_key % 32) + 30;       // 30..61 for normal ASCII
x_cycles   = (sample_progress % 6) + 1;       // 1..6
y_cycles   = ((sample_progress % 12) / 2) + 1;// 1..6
```

The initial state is scale `62`, X divisor `2`, Y divisor `2`. On an 80x25
screen the keyed amplitudes are concrete: `A` gives `(19,5)`, `M` `(26,8)`,
`Z` `(35,10)`, and `S` `(30,9)` cells before the sine multiplication. The two
cycle counts are sampled from timing at the instant of the key, so the same
letter can retain its radius while choosing a different X/Y phase relationship
on another press.

`S` additionally toggles the rolling feed and moves its write phase to
`(sample_progress + 100) % 2A94h`. The two-member set at `CS:03EFh` recognizes
Ctrl-C and `Esc`; either sets the shutdown request and redirects the main lane's
base and current pointers to the `Shutting down...` script at `DS:0236h`.

### One Clock, Seventeen Attributes

Two runtime long-arithmetic calls at `CS:07E9h..0802h` normalize sample
progress over the complete stream:

```c
phase8 = floor(sample_progress * 255 / 10900); // 0..254 during normal playback
color  = floor((phase8 % 64) * 17 / 64);       // 0..16
```

The attribute table at `DS:0202h` begins
`00,08,04,06,05,0C,0D,0E,0F,0B,0A,07,03,02,01,08,00`. Edge marks and the first
mirrored dot use `attr[color]`; the opposite dot uses
`attr[(color + 8) % 17]`. The text reveal has access to indices 1 through 17,
with the final entry also zero. This table is the source of the colored sweeps
in the runtime images; the glyphs themselves are not recolored bitmaps.

### Edge-Marker Inner Loops

The top/bottom horizontal position is:

```c
step_x = floor(10900 / (columns * 11));
edge_x = floor((sample_progress % 990) / step_x);
```

On an 80-column screen `step_x = 12`, so `edge_x` spans 0 through 82. When it
changes, the loop draws `'-'` at `(edge_x,1)` and
`(columns+1-edge_x,rows)`, then erases the two previous positions with
space/attribute `07h`. The vertical pair repeats the formula with
`step_y = floor(10900/(rows*11))`; at 25 rows that is 39, yielding positions
0 through 25. It draws `'|'` at `(1,rows+1-edge_y)` and `(columns,edge_y)`
before erasing the prior pair.

These ranges prove the absence of clipping: zero and the one-past-edge values
are sent to the low-byte writer as-is. The formulas are dimension-aware, but
not dimension-safe for arbitrary modes; a sufficiently large mode could even
make a step divisor zero. Edge updates run only while the shutdown chunk index
is `FFh`, the normal playback state.

### Sine Lookup And Quarter-Phase Pair

`DS:0002h` is a 256-word signed sine table. It runs from zero through `1023`,
back through zero to `-1023`, and ends at `-25`; every entry is within one unit
of `1024*sin(2*pi*i/256)`. The shared helper at `CS:45A0h` is:

```c
index  = trunc(phase * 255 / period);
result = trunc(sine[index] * amplitude / 1024);
```

All operands supplied by this effect are non-negative until the signed sine
multiply. `CS:45BFh` uses the X phase directly. `CS:45D2h` adds
`period >> 2`, subtracts one period on wrap, and then calls the same helper, so
Y is one quarter cycle ahead rather than coming from a second table.

For each new point:

```c
amp_x    = floor(center_column * path_scale / 64);
period_x = floor(10900 / x_cycles);
x        = scaled_sine(sample_progress % period_x, period_x, amp_x);

amp_y    = floor(center_row * path_scale / 64);
period_y = floor(10900 / y_cycles);
y        = scaled_sine_quarter(sample_progress % period_y, period_y, amp_y);
```

The result is stored in parallel 32-word X and Y arrays on the stack. If the
Manhattan difference from the previously accepted point is zero, the loop does
not rotate the ring or redraw anything. Busy traversals while the IRQ counter
has not changed therefore cost arithmetic but do not pile duplicate dots into
the trail.

### The 31-Pair Trail Ring

Three byte indices start as `current=0`, `previous=31`, and `erase=1`. On a
changed coordinate, normal playback does this:

```c
draw(center_x + x[current], center_y + y[current], 0xF9, attr[color]);
draw(center_x - x[current], center_y - y[current], 0xF9,
     attr[(color + 8) % 17]);

erase(center_x + x[erase], center_y + y[erase], ' ', 0);
erase(center_x - x[erase], center_y - y[erase], ' ', 0);

previous = current;
current  = erase;
erase    = (erase + 1) & 31;
```

The two writes use CP437 glyph `F9h`, the small centered dot visible in the
captures. All 32 coordinate slots exist, but drawing the insertion slot and
then erasing the slot one ahead leaves 31 historical mirrored pairs after
warm-up. Draw-before-erase also means an oldest point that exactly coincides
with the new point can erase the new glyph in the same traversal. No occupancy
map, duplicate suppression beyond the adjacent-point test, clipping, or
background restoration exists.

The normal amplitudes are screen-centered and bounded, but the writer still
uses only each coordinate's low byte. Pixel ownership ends at character cells:
the adapter's resident font turns `F9h`, `'-'`, `'|'`, spaces, and text bytes
into the 720x400 raster seen in the captures. `Atom` never generates those glyph
pixels itself.

## Shutdown

`Esc` or Ctrl-C requests a drain rather than jumping straight to DOS. New trail points
stop drawing, but the oldest mirrored pair continues to be erased as the ring
advances. The main text pointer changes to the short `DS:0236h` shutdown script,
and any active upper/lower token completes. Once the current full sample ends,
the chunk byte previously initialized to `FFh` advances through `0..40`.

With sample feed enabled, each stage starts this slice:

```c
offset  = chunk * 247;
length  = 246;              // one-byte gap between adjacent slices
divisor = 99 + 2 * chunk;   // 99, 101, ... 179
```

That gives 41 progressively slower short player calls. With feed disabled, the
code jumps the chunk byte directly to 40 and advances sample progress in the
main loop instead. The exit condition at `CS:0C86h..0CB1h` requires all three
lane reveal states to equal `-999`, the current player call to have
finished, and the chunk byte to equal 40. Only then does control leave the main
loop.

The same installer skip makes each nominal 246-byte shutdown slice output 245
bytes: its first byte, then bytes 2..245. With no `6Fh` markers, each stage has
1,960 output IRQs plus one completion IRQ. Weighting those 1,961 periods by the
41 divisors `99,101,..,179` gives an exact enabled-feed drain time of:

```text
sum(1961 * divisor) / 1,193,182 = 9.366332 seconds
```

Clock repair is applied separately after every short call and keeps only each
product's high word. The 41 repairs add 152 BIOS ticks, whereas the elapsed PIT
periods represent about 170.53 BIOS ticks. Repeated per-slice truncation thus
leaves the DOS clock about 18.53 ticks, or 1.02 seconds, behind after the full
enabled-feed shutdown. This does not affect the visual drain condition, but it
is a concrete lifecycle cost of splitting the tail into many player calls.

The final path clears every character byte through `CS:45F5h` while leaving the
attribute bytes untouched, resets `0040:0017` to zero, and writes `FFh` to the
floppy DOR. In the keyed run this sequence returned to the DOS prompt. The sound
ISR has already restored PIT channel 0 and the old INT 08h vector at the end of
each player call, so the high-rate timer is not left hooked.

The executable relies on the sample naturally reaching its end or on the normal
exit path. It is not a protected environment, and the embedded text explicitly
warns against running under DESQview. That warning is sensible: the demo
rewrites INT 08h, the BIOS keyboard flag byte, the floppy control port, and the
PC speaker latch directly.

## Why It Matters

`Atom` is visually simple, but its timing model is already recognizably
demoscene:

- direct text VRAM writes instead of BIOS text output,
- screen-size-aware text effects,
- a high-rate timer ISR,
- one-bit sampled audio on the internal speaker,
- visual state tied to audio progress,
- direct keyboard LED/BDA and floppy-controller showmanship,
- clock correction after abusing the BIOS timer.

For October 1990 on an ordinary PC speaker machine, the important trick is not
only the text-mode graphics. It is that one sample-byte clock drives phrase
reveals, color, edge marks, two-axis sine geometry, hardware-state events, and a
staged shutdown while the digitized one-bit sample continues in the background.
