Analysis model: gpt-5.5 xhigh, sol high
Last edited: 2026-08-25

# Mach 3 by UltraForce - Technical Dissection

`Mach 3` is cataloged by Pouet as an UltraForce MS-DOS musicdisk released in
April 1989. The archive itself complicates that date: `TOTAL.M3` and `SONG.M3`
are timestamped May 1990, `MACH3.EXE` is timestamped June 1990, and the internal
scroll text calls this the second UltraForce Sound Blaster demo after `Happy
Birthday`. I am therefore treating the public catalog year as 1989, while
explicitly noting that the examined file set looks like a 1990 package or build.

Release year: 1989 by catalog; archive/build evidence points to 1990.

This is an early Sound Blaster sample musicdisk rather than a graphics-heavy
demo. The interesting code is:

- an LZEXE 0.91 restored MZ that behaves like a COM-style load image at logical
  offset `0100h`;
- mode `0Dh` EGA setup and direct planar writes to A000h;
- a tiny menu/UI drawn from embedded planar data plus BIOS ROM 8x8 glyphs;
- a CT-VOICE driver load and far-call interface;
- an eleven-entry sample trigger table into `TOTAL.M3`, whose records are exact
  10 kHz Creative Voice type-1 blocks;
- a `SONG.M3` parser that turns text digits into sample triggers;
- a custom INT 09h keyboard IRQ handler that bypasses the BIOS key queue;
- a right-to-left carry-chain scroller that shifts an 8x320 one-plane buffer
  twice per displayed frame;
- guarded file-error exits plus an explicit CT-VOICE, IRQ, video, and DOS
  cleanup path.

The manual and program contain no private contact block in the inspected
archive. The writeup still avoids reproducing unnecessary old personal details.

## Sources

- Pouet production page:
  https://www.pouet.net/prod.php?which=4082
- Scene.org archive page:
  https://files.scene.org/view/demos/groups/ultraforce/demos/mach3.zip
- Scene.org archive download:
  https://archive.scene.org/pub/demos/groups/ultraforce/demos/mach3.zip
- Creative Technology, *Sound Blaster Series Hardware Programming Guide*,
  Creative Voice file-format appendix:
  https://cecas.clemson.edu/~ahoover/ece468/labs/SoundBlasterProgrammingGuide.pdf

Pouet gives title `Mach 3`, group `UltraForce`, platform `MS-Dos`, type
`musicdisk`, and release date `april 1989`. The scene.org group archive is the
file set analyzed below. Creative's guide is used only to identify the recovered
type-1 data-block fields and the driver's data-block pointer contract; the
Mach 3-specific offsets and behavior come from the shipped files and local run.

## Runtime Capture

Timing zero is the start of `dx-capture /v MACH3.EXE` in DOSBox-X 2026.01.02,
normal CPU core, `cycles=3000`. DOSBox-X aborted after entering a second ZMBV
capture segment, but it produced one usable graphics-mode frame before the
abort. This frame is therefore useful as a verified startup still, not as a
complete timeline.

![Mach 3 by UltraForce early runtime EGA menu frame](images/mach3-ultraforce-runtime-start.png)

The front-page card uses this verified startup still directly. I did not make a
GIF because the current capture produced only one useful graphics-mode frame
before the DOSBox-X ZMBV failure.

Observed capture:

```text
00:00.000  DOSBox-X command starts dx-capture /v MACH3.EXE.
00:00.043  First AVI segment contains only text-mode launch frames.
00:00.xxx  Second AVI segment contains one mode-0Dh EGA frame: the red
           ULTRAFORCE title, blue framed menu area, and lower menu entries.
00:00.xxx  DOSBox-X aborts with a ZMBV/double-free failure after opening the
           second capture segment.
```

The visual frame is consistent with the startup code: it has already drawn the
EGA background and part of the menu, but the capture ended before a long steady
loop could be recorded.

## Runtime-To-Code Concordance

The published frame anchors the startup screen, while a second diagnostic run
anchors the steady loop without creating new media. Nine retained silent
DOSBox-X 2024.03.01 save states (slots 2-10) used `svga_s3`, normal core, 3,000
cycles, the shipped IRQ-7 driver, dummy host video/audio, and `-silent`; host
stdout and diagnostics were redirected outside the repository. Both `sb1` and
`sb16` probes were host-inaudible. Their serialized CPU state reports
`CS=0812h` and saved `IP` values `398Ah`, `398Eh`, `3990h`, `3994h`, and
`3995h`, all inside the right-to-left 40-byte carry chain. `ES=F000h` in every
state, exactly as updater `3924h` leaves the BIOS-font segment selected.

The transition into graphics mode is explicit at `3AA0h..3AA3h`, where the
program issues BIOS mode `0Dh`. Immediately after that, `3AAEh..3ACCh` writes
the Attribute Controller palette through `03C0h`, explaining why the startup
still has a deliberately small EGA color set rather than a VGA DAC palette.

The static layout is planar, not a character screen. `3AD2h..3AF7h` selects
plane 2 and copies 19 rows of 23 bytes from `02FAh` to A000:`01E8h`: 437 source
bytes with a 40-byte destination pitch. `3B0Eh..3B2Bh` walks map masks 1, 2, 4,
and 8 and copies 141 rows x 21 bytes per plane from `04AFh` to A000:`07D9h`, or
11,844 source bytes total. The captured red title and framed blue menu are
therefore precomposed bitplanes.

The menu labels are generated separately. `39C5h` copies an 8-byte glyph from
`F000:FA6Eh`; `39F4h` writes its rows with a 40-byte pitch; and
`3B3Eh..3B68h` walks a 14x19 text matrix at `01E7h`. Of its 266 cells, 142 are
non-space glyphs and 124 are skipped. `3B70h` redraws only the three-character
beatbox `On`/`Off` field at A000:`1A08h` in plane 3, matching the independent
green status text in the frame.

The live memory map closes the loader handoffs: the far entry is
`1012:0000h`, the sample-bank base is `1812h`, current trigger is `02h`
(`1`/Get ready), beatbox starts on, and song mode and cursor start at zero. The
tested driver did not initialize—its internal ready byte at offset `65h`
stayed zero. Mach 3 never tests command 3's return value, so it still loads both
data files, hooks its keyboard IRQ, and enters the EGA main loop. The driver's
dispatcher then rejects commands 5, 6, 8, and 9 with `AX=FFFFh`, while
completion word `0812:01D3h` remains zero. This directly proves the silent
failure-path UI and scroller, not successful DAC playback.

The main frame path is now both static- and live-backed. It calls `3924h`
twice, waits for retrace high and low at `32F3h`/`32FEh`, and copies 321 bytes
from `3E63h` to A000:`03BFh` through `39A4h`. The save-state IPs are inside
those exact two updates. Sample decoding, successful CT-VOICE timing, and raw
keyboard interaction remain code/data evidence; no sample output was captured,
monitored, or auditioned.

## Archive

Examined archive:

```text
47273b1c35c01efa2104d1514c57861704da9cff4e9dff46cb468f0b065cc82d  mach3.zip
```

Contents:

```text
CT-VOICE.DRV   2377 bytes  1989-11-27
MACH3.EXE      3259 bytes  1990-06-20
SONG.M3          27 bytes  1990-05-20
TOTAL.M3     146273 bytes  1990-05-17
ULTRA4CE.DOC   4348 bytes  1990-06-12
scene.org.txt  2714 bytes  2006-05-27
```

Important file hashes:

```text
d5532401a88314a97ac0161727fb9d780302df24952248e9fb4337d673f7d30e  MACH3.EXE packed
e89c6fdb71045f56c156f299ae26db9aaf31391cc563f9a0a0d23152fdd98a49  MACH3.EXE after UNP
a7ac9b6915e636b8eaf9ccd129d254ea3532d6ec552189ba86197cee7f7822e2  restored load image
f38483af80e5df74d041dd3387859b42240a97da47cd9994e92680b20e64b2b0  CT-VOICE.DRV
f3b0da3ff866cf2f02a49f8e6fdce4dcb9347a224df2f0dc517559231e8ab4c8  TOTAL.M3
61f910b283d6f7db5972d3cf5a67dd5b300bed3a3e14bfed367017ab5899be79  SONG.M3
8c646ff26e912aaed75b5c5aee2a50b0300c092e8d7a71e14c025378ef8dcf0c  ULTRA4CE.DOC
7a3b669b99d20474163a8c8811b6adff3623066adf9bc6ae8212cc41bf030564  runtime PNG
```

`SONG.M3` is literal text:

```text
17766779787-70777-707787975
```

The manual says the sample keys are `1` through `9`, `0`, and `-`; `P` plays or
pauses the song file; `B` toggles beatbox mode; `X` exits.

## Restored MZ Shape

The packed executable is LZEXE 0.91. UNP restores it to a 15,708-byte MZ:

```text
restored file size: 15708 bytes
header size:          32 bytes
load image:        15676 bytes
relocations:           0
entry:           CS:IP = fff0:0100
stack:           SS:SP = fff0:fffe
min/max alloc:   0c73/ffff
```

The load image starts with:

```asm
0100  jmp 3a8ch
```

All offsets below are logical offsets in that `0100h`-based load image. The
physical byte offset inside the stripped load image is therefore `logical -
0100h`.

## Startup Layout

The entry at `3A8Ch` sets up two data segments above the program:

```asm
3a8c  mov ax,cs
3a8e  mov ds,ax
3a90  mov es,ax
3a92  add ax,0800h
3a95  mov es,ax
3a97  mov [018c],ax      ; CT-VOICE.DRV load segment
3a9a  add ax,0800h
3a9d  mov [018e],ax      ; TOTAL.M3 sample-bank base segment
3aa0  mov ax,000dh
3aa3  int 10h            ; EGA 320x200 16-color mode
```

So the memory map is:

```text
CS        program code/data
CS+0800h  loaded CT-VOICE driver
CS+1000h  loaded TOTAL.M3 sample bank
```

## EGA Palette And Static UI

The palette setup uses the Attribute Controller at `03C0h`:

```asm
3aae  dx = 03c0h
3ab1  al = 0
3ab5  cx = 16
3ab8  out dx,al          ; attribute index
3ab9  ah = [01bd+si]     ; palette value
3abd  xchg al,ah
3abf  out dx,al          ; attribute value
3ac0  xchg al,ah
3ac2  si++
3ac3  al++
3ac5  loop 3ab8h
3ac7  al = 31h           ; overscan/border register
3acc  out dx,al
```

The first visible block is a planar rectangle copy into A000h:

```asm
3ad2  es = a000h
3ad7  dx = 03ceh
3ada  ax = 0004h
3add  out dx,ax          ; graphics-controller read-map setting
3ade  dx = 03c4h
3ae1  ax = 0402h
3ae4  si = 02fah
3ae7  out dx,ax          ; sequencer map mask = plane 2
3ae8  di = 01e8h
3aeb  bx = 13h           ; 19 rows
3aee  cx = 17h           ; 23 bytes per row
3af1  rep movsb
3af3  di += 11h          ; 23 copied + 17 skipped = 40-byte EGA pitch
```

`01E8h = 12*40 + 8`, so this is exactly x=64..247, y=12..30. It is
the red `ULTRAFORCE` title in the runtime still: 184 pixels wide, 19 scanlines
high, and stored only in source plane 2. Palette entry 4 maps that plane value
through Attribute Controller value `3Ch`, producing the visible bright-red
title rather than an unexplained guessed color.

The second block copies a larger four-plane background/menu region. It starts
with map mask `1`, then shifts the plane mask left until it has used planes
`1`, `2`, `4`, and `8`:

```asm
3b0e  ax = 0102h         ; map mask = 1
3b11  si = 04afh
3b15  di = 07d9h
3b18  bx = 008dh         ; 141 rows per plane
3b1b  cx = 0015h         ; 21 bytes per row
3b1e  rep movsb
3b20  di += 13h          ; 21 copied + 19 skipped = 40-byte pitch
3b26  shl ah,1           ; next plane mask
3b28  cmp ah,10h
3b2b  jne 3b14h
```

The source pointer is not reset between planes, so the embedded graphics at
`04AFh` contains four consecutive 141x21-byte bitplanes. Destination `07D9h`
is x=72, y=50; the copy spans x=72..239 and y=50..190, matching the blue
panel and its border in the still. The exact 16-entry Attribute Controller list
is `00 04 02 01 3C 3C 14 07 38 3A 39 04 04 3F 02 3F`.

## Menu Text Glyph Writer

The menu entries are stored as a 14-row by 19-column text block beginning at
logical `01E7h`. The startup renderer walks it and skips spaces:

```asm
3b3e  bx = 01e7h         ; menu text pointer
3b44  di = 091ah         ; screen destination
3b48  al = [bx]
3b4a  cmp al,20h
3b4c  je 3b54h
3b4e  call 39c5h         ; fetch BIOS ROM 8x8 glyph
3b51  call 39f4h         ; write it to EGA plane
3b54  di++
3b57  bx++
3b58  dl++
3b5a  cmp dl,13h         ; 19 columns
3b62  di += 0168h        ; next row
3b68  cmp dh,0eh         ; 14 rows
```

`39C5h` uses the ROM font at `F000:FA6E`:

```asm
39ca  ds = f000h
39d7  ax = character * 8
39e1  di = 01dfh
39e4  si += fa6eh
39e8  cx = 8
39ec  rep movsb          ; copy glyph bytes into local scratch
```

`39F4h` writes that 8-byte vertical glyph to plane 2. Because `movsb` increments
`DI` once and the routine then adds `27h`, the effective stride is 40 bytes per
scanline:

```asm
39f7  ax = 0402h
39fa  dx = 03c4h
39fd  out dx,ax          ; map mask = plane 2
39fe  si = 01dfh
3a01  cx = 8
3a04  movsb
3a05  di += 27h          ; 1 copied + 39 skipped = 40-byte pitch
```

The `B` state label is rendered separately by `3B70h`; it draws either the
three-byte `On` or `Off` text at A000:`1A08h` using map mask `8`.

The 14 fixed-width source rows are themselves a useful cross-check on the
picture rather than an inferred menu description:

```text
 1.  Get ready.      2.  Well done.      3.  Game over.
 4.  Oh boy !        5.  Jetplane.       6.  Tatadada.
 7.  Chorus.         8.  Guitar1.        9.  Guitar2.
 0.  Guitar3.        -.  Guitar4.        P.  Play song
 B.  Beatbox         X.  Exit to dos
```

Each source row is exactly 19 characters. Row starts are nine scanlines apart;
142 non-space cells invoke both glyph routines and 124 spaces advance without
a draw. The separate status writer places `On`/`Off` at x=192, y=166, which is
why the captured green `On` follows the Beatbox row but is not part of the
14x19 matrix.

## CT-VOICE Driver: Calls, Gate, And Failure Boundary

The loader reads the 2,377-byte `CT-VOICE.DRV` directly into `CS+0800h` and
builds a far pointer at `018Ah`:

```asm
3bbc  open [016a]         ; "ct-voice.drv"
3bca  read ffffh bytes
3bd7  ds = [018c]         ; CS+0800h
3bdd  int 21h read
3bfe  bx = 3
3c04  far-call [018a]     ; initialize hardware
3c09  es = cs
3c0b  di = 01d3h
3c0e  bx = 5
3c14  far-call [018a]     ; install completion-word pointer
```

The driver's own dispatcher at offset `0710h` saves the caller's `ES`, changes
`DS` and `ES` to its load segment, and indexes a 14-word function table with
`BX*2`. Commands 0-3 are always admitted. Commands 4-13 first require ready
byte `[0065h] != 0`; otherwise the dispatcher returns `AX=FFFFh` without
calling the command. Command 3 at `0785h` performs DSP reset/detection, IRQ/DMA
setup, and the test interrupt that should set ready byte `65h`. Command 5 at
`07C2h` zeroes caller word `ES:DI` and stores that far pointer as the driver's
completion/marker destination.

Mach 3 checks neither return. In the retained run command 3 failed, so command
5 was rejected and the driver's built-in destination remained its own
`1012:006Ah`; Mach 3's word `0812:01D3h` happened to remain zero. Its first
call to `3D07h` and every later `BX=6` play request were rejected by the same
ready gate. This is why the observed screen remains fully live while its audio
side is not runtime evidence.

There is a second, purely static caution. The shipped driver's on-disk
command-6 table word at offset `0045h` is `94BAh`, although the matching VOC
play routine begins at `07D6h`. Initialization code at `0140h` can replace that
slot from word `006Ch`, but the shipped word is zero. The same bytes occur in
the separately archived local copies used by UltraForce's `Coldcut` and
`Witan 2`. Without a successful hardware run or a proven external patch, this
writeup therefore treats the intended command-6 interface as recovered code,
not as proof that this exact packaged driver completed playback.

## The Three-Window Sample Loader

`TOTAL.M3` is 146,273 bytes, so Mach 3 addresses it as three adjacent 64 KB
physical windows beginning at `CS+1000h`:

```asm
3c1f  open [0177]                 ; "total.m3"
3c29  read ffffh -> [018e]:0000
3c41  seek absolute 0001:0000     ; file 00010000h
3c51  read ffffh -> [018e]+1000h:0000
3c6b  seek absolute 0002:0000     ; file 00020000h
3c7b  read ffffh -> [018e]+2000h:0000
```

This is not quite a contiguous load. A `FFFFh` read covers file bytes
`00000h..0FFFEh`; the explicit seek then skips file byte `0FFFFh`. The second
read similarly skips `1FFFFh`. A live memory/file comparison found exactly
those two differences: file bytes `ABh` and `77h` became zero at bank offsets
`0FFFFh` and `1FFFFh`. They lie inside the Jetplane and Guitar3 PCM payloads,
respectively, so the bug introduces two one-sample discontinuities;
it does not move any table address.

The error checking is uneven too. Failure of the first bank read jumps to the
CT-driver error message at `3BEDh`; the second read and both seeks have no
immediate carry test; only the final read is checked before close. This is a
small but concrete sign that the loader was written around the expected fixed
files, not as a general sample-bank reader.

Before loading the song, `3CBBh..3CC3h` zeroes 430 bytes at
`3E3Bh..3FE8h`. That range includes the entire 321-byte scroller publisher
buffer, so its first visible passes shift known zeroes rather than stale DOS
memory. `SONG.M3` then loads immediately after it at `3FE9h`, with the returned
27-byte count stored at `01CEh`:

```asm
3cbb  di = 3e3bh
3cbe  cx = 01aeh
3cc1  ax = 0
3cc3  rep stosb
3cc9  open [0180]                 ; "song.m3"
3cdc  read -> 3fe9h
3ce3  [01ce] = ax                 ; actual byte count
```

## Sample Table And Embedded Voice Blocks

The trigger routine accepts a scan-code-like value in `0190h`, subtracts 2,
rejects releases and values outside the eleven-key range, and indexes 4-byte
`segment addend, offset` records at `0191h`:

```asm
3d07  al = [0190]
3d0a  al -= 2
3d0f  test original value as make/break code
3d1d  si = zero_extend(al) * 4
3d25  ax = [0191+si]              ; segment addend
3d2c  di = [0193+si]              ; block offset
3d30  bx = 6                      ; CT-VOICE play data block
3d33  ax += [018e]                ; bank base segment
3d39  es = ax
3d3e  far-call [018a]
```

Normalizing each far pointer to a linear bank offset reveals eleven exact
Creative Voice type-1 blocks:

```text
key  menu label  far addend:offset  bank start  PCM bytes  duration
1    Get ready   0000:001a           00001a       19690    1.9690 s
2    Well done   0000:4d25           004d25        9723    0.9723 s
3    Game over   0000:7341           007341       10874    1.0874 s
4    Oh boy      0000:9ddc           009ddc       11872    1.1872 s
5    Jetplane    0c00:0c5d           00cc5d       15500    1.5500 s
6    Tatadada    1000:090a           01090a       34458    3.4458 s
7    Chorus      1000:8fc5           018fc5        8597    0.8597 s
8    Guitar1     1000:b1e2           01b1e2        8700    0.8700 s
9    Guitar2     1000:d3ff           01d3ff        8664    0.8664 s
0    Guitar3     1c00:35f8           01f5f8        8802    0.8802 s
-    Guitar4     1c00:587b           02187b        8927    0.8927 s
```

Every target starts with block ID `01h`, a 3-byte little-endian block length,
time constant `9Ch`, and codec `00h`. For this old type-1 grammar, the length
includes the time-constant and codec bytes; PCM count is therefore
`block_length - 2`. The recovered rate is exact:

```text
1,000,000 / (256 - 9Ch) = 10,000 samples/second
```

The file is not a valid top-level VOC. Before ten of the blocks is a 26-byte
header-shaped record whose 19-byte identifier is garbage, although its tail is
the plausible `1A 1A 00 0A 01 29 11`; the first record begins with
`524p7%^yfgdgfd334%6` rather than `Creative Voice File`. Each ordinary gap is
27 bytes: one zero terminator plus that malformed 26-byte wrapper. Chorus to
Guitar1 has a 130-byte gap instead, adding 103 mostly `7Fh` bytes. This does not
confuse the intended driver path because Mach 3's table points directly to each
type-1 data block, exactly the data-block-only contract documented by Creative.
The Guitar4 block ends at `23B60h`; the final byte at `23B60h` is its zero
terminator and the file ends one byte later.

## Song Parser

When song playback is enabled (`[01D0] == 1`) and CT-VOICE says the current
sample has finished (`[01D3] == 0`), the main loop advances through the loaded
`SONG.M3` text:

```asm
3d53  si = [01d1]         ; song cursor
3d57  [01d1]++
3d5b  cmp si,[01ce]       ; end of song data?
3d61  toggle [01d0] and reset cursor if done
3d6f  si += 3fe9h
3d73  al = [si]
3d75  if '-' then al = 0ch
3d7e  if '0' then al = 0bh
3d87  otherwise al -= 2fh ; '1'..'9' -> 02h..0ah
3d89  invalid byte? jump back to 3d53h in the same loop pass
3d8f  [0190] = al
3d92  call sample trigger
```

So `SONG.M3` is deliberately editable text. Its bytes are the same keys a user
would press manually; invalid bytes are skipped immediately rather than taking
a frame. `P` toggles the play flag but preserves the cursor. Reaching byte 27
toggles song mode off and resets the cursor to zero, ready for the next `P`.

The exact sequence has these trigger counts:

```text
7 x15   6 x2   9 x2   8 x2   - x2   0 x2   1 x1   5 x1
```

Summing the recovered 10 kHz block lengths gives 30.3247 seconds of nominal
serial sample time, before driver/DMA overhead or manual interruption. The song
contains no delay opcode: progression is entirely completion-word driven. On
the observed failed-driver path that word never becomes busy, so pressing `P`
would make the parser reject one requested sample per frame and exhaust the
27 trigger bytes in 27 frames; the next parser visit toggles song mode off and
rewinds. Song mode was left off during the retained state run.

## Keyboard IRQ Handler

Mach 3 does not use BIOS `INT 16h`. It installs its own INT 09h handler:

```asm
3a53  ax = 3509h
3a56  int 21h             ; get old INT 09h vector
3a58  save old offset/segment at 3a0e/3a10
3a60  dx = 3a1eh
3a69  ax = 2509h
3a6c  int 21h             ; install custom handler
```

The handler reads the raw scancode from port `60h`, acknowledges the keyboard
controller through port `61h`, briefly enables interrupts, stores the code,
disables interrupts again for PIC EOI, and returns without chaining to BIOS:

```asm
3a26  in al,60h
3a29  in al,61h
3a2d  or al,80h
3a2f  out 61h,al
3a31  restore old 61h value
3a35  sti
3a3b  [01d5] = 1          ; key pending
3a41  [01d6] = scancode
3a45  cli
3a46  al = 20h
3a48  out 20h,al          ; PIC EOI
3a52  iret
```

This is a one-entry latch, not a queue: another keyboard IRQ before the main
loop consumes `[01D5h]` can overwrite `[01D6h]`. Because the handler never
chains, BIOS does not see these keys and its `INT 16h` queue is irrelevant. The
main-loop make/break test accepts original values `00h..7Fh` and rejects
`80h..FFh`, so releasing a control does not repeat its action. On exit,
`3A75h` restores the old INT 09h vector.

Raw scan-code controls:

```text
02h..0Ah  keys 1..9, sample triggers
0Bh       key 0, Guitar3 sample
0Ch       key -, Guitar4 sample
19h       key P, toggle song playback
2Dh       key X, exit
30h       key B, toggle beatbox mode and redraw On/Off
```

If beatbox mode is on, a manual sample key first sends CT-VOICE command `BX=8`
before command 6 triggers the new sample. With beatbox off it goes directly to
command 6, leaving the driver's busy state to accept or reject overlap. Thus
the toggle changes sample replacement policy, not tempo generation. `P` merely
toggles song mode, `B` redraws the independent three-glyph status field, and
`X` enters the full teardown path.

## Main Loop

The loop begins at `3D42h`:

```asm
3d42  call 3d07h          ; current sample trigger path
3d45  if [01d0] != 1, skip song parser
3d4c  if [01d3] != 0, skip song parser
3d53  advance song cursor and maybe set [0190]
3d95  call 3924h
3d98  call 3924h          ; scroll update twice per frame
3d9b  call 32f3h          ; wait for vertical retrace high
3d9e  call 32feh          ; wait for retrace low
3da1  call 39a4h          ; copy scroller buffer to A000h
3da4  if no key pending, loop
3dac  consume [01d6] and handle X/B/P/sample keys
```

The entry jump lands at `3D42h`, not `3D45h`, so initialized value
`[0190h]=02h` makes one automatic Get-ready request before the steady loop.
Later iterations return to `3D45h` and only trigger from the song parser or a
new manual make code.

The retrace helpers are direct reads from input status register `03DAh`:

```asm
32f3  cli
32f4  dx = 03dah
32f7  in al,dx
32f8  test al,08h
32fa  wait until set
32fc  sti

32fe  cli
32ff  dx = 03dah
3302  in al,dx
3303  test al,08h
3305  wait until clear
3307  sti
```

The first helper waits for bit 3 to become set and the second waits for it to
clear, with interrupts disabled throughout both polls. Consequently the two
scroll shifts happen before retrace, and the 321-byte EGA publish starts just
after retrace ends. The long `CLI` window delays both the keyboard IRQ and any
CT-VOICE IRQ rather than allowing them to run during the frame wait.

## Scroller Inner Loop

The scroller is an 8-pixel-high, full-width planar strip, not an EGA text line.
Its updater starts at `3924h` by loading `ES=F000h`, which is why every retained
state inside the shift loop has the ROM segment still in `ES`.

Every eighth call it fetches a new character from the internal scroll text at
`3309h`; zero at `3752h` terminates and wraps the text. The payload is 1,097
bytes, 848 of them non-space:

```asm
3929  [01cd]++
392d  cmp [01cd],8
3934  [01cd] = 0
3939  ax = [3753]         ; text cursor
393c  [3753]++
3943  al = [3309h+si]
3947  if al == 0, reset cursor and fetch again
```

It then copies the character's eight ROM-font rows into scratch bytes
`01D7h..01DEh`:

```asm
3957  ax = al * 8
395d  si = ax
3963  al = es:[si+fa6eh]  ; ROM 8x8 font
3968  [01d7+di] = al
396c  si++
396d  di++
3970  repeat 8 rows
```

The shift uses carry as the one-bit handoff between the scratch glyph and one
screen row. For each of eight glyph rows:

```asm
3975  si = 0028h          ; end of first 40-byte row
397a  clc
397d  al = [01d7+di]      ; one glyph row
3981  rcl al,1            ; old bit 7 becomes incoming pixel
3983  [01d7+di] = al
3987  cx = 0028h
398a  al = [3e63h+si]
398e  rcl al,1            ; propagate right-to-left through row
3990  [3e63h+si] = al
3994  si--
3995  loop 398ah          ; shift 40 bytes
3997  si += 0050h         ; next row: -40 + 80 = +40
399a  di++
399b  clc                  ; isolate the next glyph row
399c  bl++
399e  repeat 8 rows
```

The reverse byte order is the key detail. EGA stores the leftmost pixel in bit
7. Rotating byte 40 first inserts the glyph bit at the rightmost screen pixel;
its old bit 7 then enters byte 39's bit 0, and so on toward byte 1. Within each
byte `RCL` moves existing pixels one position left. The result is a true
one-pixel left shift with the next glyph column entering at x=319, performed
without a 320-pixel loop or an auxiliary old-frame buffer.

`[01CDh]` advances once per call. Since the main frame calls `3924h` twice, the
strip moves two pixels per displayed frame and a fresh 8-pixel glyph is loaded
every four frames. Its compiled initial value is `07h`, so the very first call
loads the first glyph rather than waiting through seven blank updates. Each
frame performs 2 x 8 x 40 = 640 in-place buffer-byte rotates, plus sixteen
scratch-byte rotates. No separate erase pass is needed: the shifted 320-byte
plane image is the new frame.

The buffer copy to visible EGA is then just:

```asm
39a4  es = a000h
39aa  sequencer map mask = plane 0
39b1  graphics-controller read map = 0
39b8  si = 3e63h
39bb  di = 03bfh
39be  cx = 0141h
39c1  rep movsb
```

The apparently odd 321-byte size is an alignment device. Buffer byte 0 at
`3E63h` is never changed; destination `03BFh` is row 23, byte 39, immediately
before the real strip. Updated source bytes 1..320 therefore land exactly on
rows 24..31, all 40 bytes of each row. The publisher selects map mask 1, so it
replaces plane 0 only; the static color information already present in planes
1-3 remains untouched. This full-strip overwrite is also the old-frame cleanup
strategy. These are near-top scanlines through the lower title band, not a
bottom-of-screen scroller; the early still catches that strip before readable
scroll text has traversed it.

The loop is compact but not inferred: retained instruction pointers hit
`398Ah`, `398Eh`, `3990h`, `3994h`, and `3995h`, covering load, rotate, store,
decrement, and loop control in the exact inner chain. It is the only
continuously animated visual path in this program; the title, frame, menu, and
beatbox label are otherwise static except when `B` explicitly redraws that
label.

Normalized pseudocode for one update is:

```text
if (++phase == 8):
    phase = 0
    glyph[0..7] = ROM8x8[next_wrapping_text_byte]

for row = 0..7:
    carry = glyph[row].bit7
    glyph[row] <<= 1
    for byte = 39 down to 0:
        (buffer[row][byte], carry) = rcl(buffer[row][byte], carry)
```

The actual array begins at source offset 1 because of the guard byte described
above; the pseudocode removes that alignment quirk, not any work from the loop.

## Exit And Partial-Failure Cleanup

The `X` make code (`2Dh`) branches to `3E12h` and unwinds the hardware-facing
state in a fixed order:

```asm
3e12  bx = 8; far-call [018a]     ; stop current voice
3e1b  bx = 9; far-call [018a]     ; shut down CT-VOICE
3e24  call 3a75h                  ; restore old INT 09h vector
3e27  ax = 0003h; int 10h         ; restore 80x25 text mode
3e2c  ds = cs
3e30  dx = 3755h; ah = 09h
3e35  int 21h                     ; final message
3e37  ah = 4ch; int 21h           ; return to DOS
```

Commands 8 and 9 are still safe on the observed no-driver path because the
ready gate rejects them before dispatch. The program does not explicitly set
`AL` before DOS function `4Ch`, so its normal exit status is not deliberately
defined.

The three file-error paths are shorter. Driver-open failure at `3BEDh`, bank
failure at `3CA4h`, and song failure at `3CF0h` each restore text mode, print a
specific `$`-terminated message, and exit with `AX=4C00h`. They occur before
Mach 3 installs its own INT 09h, so no keyboard vector needs restoring. The
bank and song failures do occur after command 3, however, and do not call
CT-VOICE command 9; on hardware where initialization succeeded, those paths
could leave the driver's IRQ/vector setup installed. The normal `X` route is
the only complete teardown.

## What Mach 3 Does

In practical terms, `Mach 3` is a Sound Blaster demonstration shell:

1. switch to EGA mode `0Dh`;
2. draw a static UltraForce/menu screen with direct planar copies and BIOS-font
   glyphs;
3. load `CT-VOICE.DRV` into a private segment and call it through a far pointer;
4. load `TOTAL.M3` into three 64 KB sample-bank windows;
5. optionally read a text song sequence from `SONG.M3`;
6. hook INT 09h and use raw scan codes for low-latency keys;
7. map sample keys to segment/offset records in the sample bank;
8. shift an 8x320 plane-0 scroller twice per frame and publish it after
   vertical retrace;
9. stop/shut down the voice driver, restore INT 09h and mode 3, and return to
   DOS on `X`.

That makes it historically interesting even though the graphics are small: the
program is an early PC/Sound Blaster "musicdisk" built before generalized module
players became normal in PC demos. Its graphics side is especially economical:
precomposed bitplanes make the UI cheap, the ROM supplies every glyph, a
one-byte key latch replaces BIOS input, and a carry chain turns 640 byte rotates
into a two-pixel-per-frame full-width scroll. The audio side is equally direct
in design—text keys into type-1 voice blocks—but the packaged driver's failed
and anomalous command-6 paths are kept separate from what the runtime actually
proved.
