Analysis model: gpt-5.5 xhigh

# Dentro Demo by Ultra Force - Technical Dissection

## Scope

This is a static dissection of `Dentro Demo` by Ultra Force, an MS-DOS VGA
Sound Blaster dentro released in August 1992 as the intro/presentation sequence
for the unreleased `Pandora's Box` megademo.

Sources:

- Pouet prod page: https://www.pouet.net/prod.php?which=4088
- Scene.org archive: https://files.scene.org/get/demos/groups/ultraforce/demos/dentro.zip
- Scene.org group directory: https://files.scene.org/browse/demos/groups/ultraforce/demos/

I unpacked the `.COM`, disassembled the unpacked real-mode image, and mapped the
asset loader against `DENTRO.DAT`. The names below are therefore mostly runtime
behavioral names, not original source labels. When I call a part `caption`,
`picture strip`, `scroller`, `lazerbob`, or `palette copper`, that is a
description of what the code is doing at that address.

## Archive Contents

The archive contains:

```text
DEMOSITE.COM   small site/loader helper
DENTRO.COM     packed executable
DENTRO.DAT     compressed resource file
ORDER.FRM      Ultra Force public-domain order list
README.UF      Ultra Force advertisement/readme
WANTED.TXT     contact/recruitment text
```

Hashes of the files used here:

```text
239933250e975eb3faefad6d58e7ce79021d9256a55430f67292fb7be264d5f0  dentro.zip
16988f8c1f18b5a85c325d23e0438b850efba0fab21954af5db5b05a2f2f4ab4  DENTRO.COM
55431165d4a22630f71722eebb169123ffe23d0466637af2b7a5461f23a28957  DENTRO.DAT
7988dc5a17ed871cf720b28f431a41e2a6f7453b3f0e3ee865434af2246a1c59  unpacked DENTRO.COM image
```

`ORDER.FRM` lists the earlier public-domain Ultra Force releases:

```text
Space demo, Roger Rabbit, Spacefun, Coldcut, Sphinxdemo, Mach 3, VEGA,
Rebelfun, Ultrawow, Birthday, Jmplayer, Bart's Law, Vectordemo,
Dentro for Pandora's Box
```

The readme says Ultra Force had recently released "almost nothing" because they
were working on games, the Pandora's Box presentation, a music editor, a
multimedia player, and commercial presentation/toolbox work. That matches the
shape of this prod: it is not a standalone narrative demo so much as a glossy
showreel and promise of a bigger system.

## Packed COM

`DENTRO.COM` is not the code that actually runs the show. It starts with a
self-unpacking stub. The stub does three jobs:

1. It checks memory/stack conditions and prints a DOS `$` string if startup
   cannot continue.
2. It copies a small second-stage depacker from the loaded COM body to a safer
   scratch address and enters it with a far return.
3. The second-stage code relocates the packed byte stream upward, inflates it
   back down to offset `0100h`, and far-returns into the unpacked image.

The extracted runtime image occupies offsets `0100h..DE8Fh`, 56,719 bytes.
The original packed file is 17,271 bytes, so the executable-side packing ratio
is a little over 3:1 before `DENTRO.DAT` enters the picture.

The depacker's exact bit coding is separate from the later `UFEO` resource RLE.
That distinction matters: the COM packer is an executable compressor; the asset
blocks in `DENTRO.DAT` use a much simpler byte-run format that the show calls
repeatedly at runtime.

## Runtime Entry

The unpacked image starts at `0100h`:

```asm
0100: pop si
0101: pop di
0102: mov ax, cs
0104: mov ds, ax
0106: mov es, ax
...
```

The first few instructions normalize `DS` and `ES` to the code segment, clear a
few state bytes, and then perform the compatibility checks:

- `int 10h` with `AX=1A00h` asks for VGA display combination state.
- The code requires `AL=1Ah` and accepts display type `BL=07h` or `BL=08h`.
- Failure jumps to the common DOS text-exit routine at `1A73h`.
- `0209h` performs the memory check. The user-facing error string says the demo
  wants 512 KiB, or 320 KiB when `/NOSB` is used.
- `029Fh` installs a trivial Ctrl-Break vector, pointing the interrupt to a
  `retf` at `02B5h`, so DOS break handling cannot tear down the show in the
  middle of VGA/SB state.

The command-line parser at `0BBFh` uppercases the PSP command tail in place and
then scans for slash-prefixed tokens. Recognized switches:

```text
/NOSB      disable Sound Blaster path and use the lower-memory layout
/LOOP      loop the presentation
/GOBLINS   skip forward to a later/hidden sequence
/VERSION   print "Versionnumber of this dentro is v1.02."
/KEY       print a hidden admonishing message
```

Unknown parameters print the built-in help text and exit. The parser is a simple
`repne scasb` search for `/`, followed by literal token comparisons.

## DAT File Layout

`DENTRO.DAT` is a flat resource file. The visible block marker is `UFEO`, but
the code seeks to one byte before most markers. That byte is treated as part of
the per-block header and is skipped together with the four marker bytes by the
decoder's initial `add si,5`.

Confirmed `UFEO` markers:

```text
000001  UFEO
00DCBC  UFEO
00E4CA  UFEO
00E6DA  UFEO
00F1A4  UFEO
01EAA8  UFEO
025FE5  UFEO
02621E  UFEO
0266D1  UFEO
```

The code usually seeks to `marker_offset - 1`:

```text
000000  initial title/working graphics block
00DCBB  second graphics block
00E4C9  small block, decoded to CS+1000:0800, output 0x0C00 bytes
00E6D9  block decoded to CS+1000:6800, output 0x1800 bytes
00F1A3  large block decoded to CS+1000:8000, output 0x7880 bytes
01EAA7  final-part picture block, output 0xFA00 bytes
025FE4  palette block, output 0x0300 bytes
02621D  final-part picture block, output 0xFA00 bytes
0266D0  final-part picture block, output 0xFA00 bytes
```

The generic loader at `2FD3h` opens `DENTRO.DAT`, seeks to the caller-provided
file offset in `DX`, reads `CX` bytes into a high scratch segment, computes the
requested output length from `BX`, and enters the `UFEO` decoder with output at
`CS+1000:DI`.

## UFEO RLE Inner Loop

The asset decoder at `0C9Bh` is the cleanest inner loop in the demo:

```asm
0C9B: add si, 5        ; skip header byte + "UFEO"
0C9E: dec cs:[0C99]    ; adjust low-byte output target
0CA3: xor dx, dx       ; output byte count within current 4K window
0CA5: mov bx, dx       ; output window count, in segment increments

token:
0CA7: xor ah, ah
0CA9: lodsb
0CAA: mov cx, ax
0CAC: push cx
0CAD: cmp al, 80h
0CAF: jae fill_run

literal_run:
0CB1: rep movsb
0CB3: jmp after_run

fill_run:
0CB5: and cx, 7Fh
0CB8: lodsb
0CB9: rep stosb

after_run:
0CBB: pop cx
0CBC: and cx, 7Fh
0CBF: add dx, cx
0CC1: cmp dx, 1000h
0CC5: jl same_window
0CC7: sub dx, 1000h
0CCB: add bx, 0100h
0CCF: sub di, 1000h
0CD3: mov ax, es
0CD5: add ax, 0100h
0CD8: mov es, ax
same_window:
0CDA: cmp cs:[0C97], bx
0CDF: je maybe_done
0CE1: jmp token
maybe_done:
0CE3: cmp cs:[0C99], dx
0CE8: jle done
0CEA: jmp token
done:
0CEC: ret
```

In pseudocode:

```c
si += 5;
out_page = 0;
out_low = 0;

for (;;) {
    token = *si++;
    count = token & 0x7f;

    if (token < 0x80) {
        copy count bytes from input to output;
    } else {
        value = *si++;
        write value count times to output;
    }

    out_low += count;
    if (out_low >= 0x1000) {
        out_low -= 0x1000;
        out_page += 0x100;
        di -= 0x1000;
        es += 0x100;
    }

    if (out_page == target_page && out_low >= target_low)
        break;
}
```

The only compression idea is "literal run or repeated-byte run", with a 7-bit
count. The interesting engineering is the real-mode address maintenance: output
advances through memory as a logical linear stream, but every 4 KiB the code
bumps `ES` by `0100h` paragraphs and subtracts `1000h` from `DI`. That avoids
needing 32-bit arithmetic while still decoding blocks larger than one offset
window.

## Show Script

The main show driver starts at `02B6h`. Its first phase clears text-renderer
state bytes at `284Bh..284Eh`, loads the initial data blocks, sets graphics
state, installs the keyboard hook, copies the first title image, and initializes
sound if enabled:

```asm
02C6: push cs:[07D2]
02CB: call 192A   ; load first DAT block
02CE: call 1CBC   ; video init
02D1: call 2E21   ; black DAC
02D4: call 18FB   ; attribute palette reset
02D7: call 0A76   ; keyboard hook
02DA: call 1A41   ; planar title copy
02DD: call 09D5   ; load second DAT block
02E0: call 2FD3   ; load block at 00E4C9
02EF: call 2FD3   ; load block at 00E6D9
02FE: call 19B4   ; load block at 00F1A3
031B: call 17C6   ; optional Sound Blaster init
0329: call BE6D   ; sound pump
032E: call BE6D   ; sound pump
```

After this, the code is a hand-authored presentation script: set a palette
range, draw a caption, fade it in, wait, fade it out, blit a picture region,
repeat. Captions embedded around `14BCh` include:

```text
vectorcubes
shadeballs
heat seeking radar
the adventures of kool moo di
a totally mind blowing house part
and technoshade:
lazerbobs: sb pro support: secret rooms: anti-gravity
scrolling: fournier vectors: defractating vector dots:
and more
now enjoy the following part
there is a secret key in here
```

The common caption routine at `0F3Eh` blanks selected DAC entries, calls the
text renderer, fades the chosen palette source in, waits `cs:[0F3B]` frames,
then fades back out. The visible "parts" in the early presentation are therefore
not independent engines; they are mostly still pictures and text, orchestrated
by palette and blit routines.

## VGA Timing And Sound Pump

The vblank routines are small but central:

```asm
2F8A: mov dx, 03DAh
wait_in_vblank:
      in  al, dx
      test al, 08h
      je wait_in_vblank
      ret

2F93: if sound_active && sb_enabled:
          push regs
          push cs
          call BE6Dh
          pop regs
      mov dx, 03DAh
wait_out_of_vblank:
      in  al, dx
      test al, 08h
      jne wait_out_of_vblank
      ret
```

Most palette and blit routines call `2F93h` followed by `2F8Ah`: first wait
until the previous retrace window has ended, then wait until the next one
begins. The same wait also services the embedded Sound Blaster system through
`BE6Dh`, so frame pacing and audio servicing are tied together. That is why
`/NOSB` is more than a mute switch: it changes which memory/scratch layout and
which per-frame calls are active.

## Palette Inner Loops

`2E21h` blackens the first 128 DAC entries twice:

```asm
2E21: mov dx, 03C8h
      xor ax, ax
      out dx, al       ; start color 0
      mov cx, 0080h
      call 2F93
      call 2F8A
      mov dx, 03C9h
loop: out dx, al       ; red = 0
      nop
      out dx, al       ; green = 0
      nop
      out dx, al       ; blue = 0
      nop
      loop loop
      repeat once
```

`2E5Eh` blanks arbitrary palette ranges. The range table is:

```text
cs:2E4C      number of ranges
cs:2E4E...   start,end byte pairs
```

For each pair, it writes `start` to DAC address port `3C8h`, then streams zero
RGB triples to `3C9h` until it reaches `end`. If the current color index reaches
`80h`, it stops and waits for another retrace before continuing. This prevents a
long DAC upload from straddling the wrong part of the scanout.

The fade-in routines use 64 steps because VGA DAC channels are 6-bit. The core
idea in `2BD7h` and its near-duplicates is:

```c
current_palette = zeros;

for (step = 0; step < 64; step++) {
    threshold = 64 - step;

    for (i = 0; i < 0x300; i++) {
        if (source_palette[i] >= threshold)
            current_palette[i]++;
    }

    upload_configured_ranges(current_palette);
}
```

Fade-out is the inverse: copy a 768-byte RGB palette to a working buffer, then
decrement every nonzero component once per frame and upload the configured
ranges. The result is deterministic and cheap: no multiplication, no division,
only comparisons and byte increments/decrements.

## Picture Copies

The title and picture blitters are deliberately simple, with vblank waits placed
around large copies.

`1A41h` copies planar data to VGA memory. It sets Sequencer index 2, starts with
map mask `01h`, copies `9600h` bytes for that plane, shifts the map mask left,
and repeats until the mask reaches `10h`. That is a classic planar VGA load:
the source is arranged per bitplane, and the destination is always `A000h`.

The later mode-13h picture routines use `rep movsb` in visible scanline-sized
chunks:

```text
2A2A  copy 0x2580 bytes from CS+1800:0000 to A000:0C80
2AAB  copy 11 chunks of 0x0C80 bytes plus a 0x0500-byte tail
2ADA  copy 13 chunks of 0x0C80 bytes plus a 0x0500-byte tail
2B09  copy 10 mini-lines of 0x00DC bytes with 0x0064-byte gaps
```

`0x0C80` is 3200 decimal, exactly ten 320-byte mode-13h scanlines. These
routines are not drawing procedural effects; they are timed picture reveals
using big memory moves and palette transitions.

## Text Renderer

The caption renderer starts at `274Eh`. It consumes a `$`-terminated text stream
and treats a few bytes as inline layout commands:

```text
space   advance one cell
#       line/section break; add a large row stride to the cursor
%       half-cell/phase toggle for centered or split text
$       terminator
```

Normal characters dispatch to one of two glyph paths:

- `284Fh`: compact packed/nibble glyph path.
- `2964h`: wider 12-byte glyph path.

The compact path maps letters and digits to glyph offsets, with odd/even state
kept in bytes around `284Bh..284Eh`. It then writes 16 scanlines into `A000h`.
The inner row loop repeatedly mixes source nibbles with the destination byte
using Graphics Controller bit mask register 8:

```asm
; one representative row from the packed path
out 03CEh, 080Fh      ; select/write a low-nibble mask
mov al, es:[di]       ; pull existing destination byte through VGA latch
xchg bx, ax
stosb                 ; write mixed byte
out 03CEh, 08FFh      ; full-byte mask for following store
lodsb
stosb
add si, 26h           ; next glyph row in packed source layout
add di, 26h           ; next screen row/position stride
loop row
```

There are several branches because a glyph can begin on a half-byte boundary.
If it is misaligned, the code splits one source byte across adjacent destination
bytes by shifting nibbles:

```asm
shr al, 4
...
and al, 0Fh
shl al, 4
...
and next, 0F0h
shr next, 4
add al, next
```

The wide path at `2964h` is simpler. It maps:

```text
letters: (ch - 'a') * 12 + 0x4000
digits:  (ch - '0') * 12 + 0x1400 + 0x4000
```

Then it copies 16 rows of 12 bytes each:

```asm
mov cx, 10h
row:
    push cx
    mov cx, 0Ch
    rep movsb
    pop cx
    add si, 0134h
    add di, 0134h
    loop row
```

That `0134h` row stride is 308 decimal. Since each row already copied 12 bytes,
the total vertical advance is 320 bytes per row, i.e. one mode-13h scanline.

## Final Tweak-Mode Part

The long final section starts at `3128h`. It is the part Pouet comments allude
to when they mention many animation layers.

Setup flow:

```asm
3138..318C  reset final-part state and copy palette tables
3194..3223  load/decode block at 01EAA7, output 0xFA00 bytes to CS+2000
322C        call 35B7, mode 13h plus VGA register tweaks
323B        load/decode palette block at 025FE4
3262..3288  deinterleave decoded image bytes into VGA planes
3296        load/decode another final picture block
329F        initialize moving-object tables
32FE..33E6  main final-frame loop
```

`35B7h` starts from BIOS mode `13h` but then reprograms VGA registers:

- Sequencer memory mode/index 4 is written with `0604h`.
- Sequencer synchronous reset is toggled with `0100h` and `0300h`.
- CRTC register `11h` is unlocked.
- CRTC registers `06h`, `07h`, `09h`, `10h`, `11h`, `12h`, `14h`, `15h`,
  `16h`, and `17h` are rewritten.
- VGA memory is cleared directly at `A000h`.

This is not plain chunky mode 13h anymore. The code is using an unchained/tweaked
VGA layout where map masks, CRTC start address, and plane-separated data matter.

The image deinterleave at `3262h` shows the memory format:

```asm
mov ax, 0AC00h
mov es, ax
mov cx, 3E80h
mov dx, 03C4h
mov ax, 0102h        ; map mask = plane 0
xor si, si
mov di, si

plane:
    out dx, ax
    push si
    push di
copy:
    movsb            ; write one byte to selected VGA plane
    add si, 3        ; skip the other three interleaved plane bytes
    loop copy
    mov cx, 3E80h
    pop di
    pop si
    inc si           ; next source phase
    shl ah, 1        ; next map mask
    cmp ah, 10h
    jne plane
```

So the decoded block is stored as interleaved four-plane image data. The loader
walks source phases 0, 1, 2, 3 and writes each phase to a different VGA plane.

## Final Scroller Inner Loop

The scroller core is at `3AAEh`. It uses text at `3613h` and state variables
around `39DBh` and `3AA1h..3AADh`.

The parser:

```asm
3AD2: si = cs:[39DB]
3AD7: al = cs:[3613 + si]
3ADC: if al == 0, wrap to start text
3AEC: if al == '#', read next byte as effect mask command
3AF6: not al
3AF8: and cs:[3AAD], al
3B09: al -= '_'
3B0D: si = al * 4
3B17: width = cs:[39DD + si]
3B27: glyph_base = cs:[39DD + si + 2]
```

`#` does not mean newline in this final text; it is an inline effect-control
command. It masks bits out of `3AADh`, and the main frame loop tests those bits
to enable or suppress individual subeffects.

The actual draw loop:

```asm
3B46: di = cs:[3AA7] - 2
3B4E: cx = 1Bh             ; 27 rows
3B51: es = A000h
3B56: ds = AC00h           ; A000h + 0C00h as a segment alias
3B5B: map mask = 0Fh
3B62: GC mode register = write mode/read mode variant

row:
3B6F: al = ds:[si]
3B71: es:[di] = al
3B74: di += 52h
3B77: es:[di] = al
3B7A: di += 50h
3B7D: si += 50h
3B80: loop row
```

Each glyph row byte is written twice, separated by `52h` bytes, then the next
row starts `50h` bytes later. The combined destination advance per source row is
`A2h`. This is not a normal 320-byte linear framebuffer stride; it is the tweaked
planar layout's row/column stepping.

The paired routine at `3B99h` scrolls by changing the CRTC display start:

```asm
3B9B: inc cs:[3AA7]
3BA0: if cs:[3AA7] == 6E70h, reset to 6E1Eh
3BB5: wait until 3DAh bit 3 is clear
3BBA: burn 012Ch loop cycles
3BC9: wait until 3DAh bit 3 is set
3BCE: out CRTC index 0Ch, start high
3BD9: out CRTC index 0Dh, start low
```

That is a hardware scroll. The text routine draws new material into the rolling
buffer; the CRTC start-address update moves the viewport.

## Final Effect Scheduler

The final frame loop at `32FEh` is the closest thing to a real multi-effect
engine in the dentro:

```asm
32FE: call 3AAE   ; advance/draw scroller text column
3301: call 3108   ; check for a magic on-screen/key/string condition
3304: test cs:[3AAD], 04h
330C: call 4DE2   ; letter/ribbon prepass if enabled
331B: call 51DB   ; alternating draw variant
331E: call 53EF
3321: call 55AA
3337: call BE6D   ; SB pump
333B: call 3B99   ; hardware scroll
3346: call 4301   ; palette table upload, copper-like color motion
3351: call 498F   ; additional palette/range updater
335C: call 4A29   ; lazerbob/vector-dot family
3370: call 4D54   ; moving sprite/head copy
33D8: call 4290   ; palette postpass
33E3: call 481F   ; palette postpass
33E6: jmp 32FE
```

The mask byte `3AADh` decides which calls are live. The scroll text can change
that byte with inline `#` commands, so the text stream acts as a lightweight
timeline for the effect stack.

The palette routines around `4301h`, `481Fh`, and `498Fh` stream prepared RGB
tables to DAC entries such as colors `06h..1Ah`, `45h`, `90h`, and `F0h`. This
is "copper-like" in the PC/VGA sense: not an Amiga copper, but synchronized
palette register rewriting used as an animation layer.

The moving-dot/lazerbob family around `4A29h` dispatches to routines at
`4AE9h`, `4BC2h`, and `4C9Dh`. They maintain small `(base, phase)` pairs,
advance phase counters, and write bytes through VGA map-mask/GC state to moving
positions. The important point is that these are not full bitmap blits; they are
small planar writes into the already-scrolling/tweaked display.

The sprite routine at `4D54h` copies small 13-byte spans from one VGA/source
region to another. Its source position changes every frame, and a longer counter
switches the sprite base table after roughly a few hundred frames. The repeated
`si += 1F02h` and line-wise subtraction by `A2h` line up with the same tweaked
layout stride used by the scroller.

## Keyboard Hook

The installed input handler at `0AC1h` is a keyboard-controller style hook:

```asm
in  al, 60h       ; scan code
in  al, 61h
or  al, 80h
out 61h, al
and al, 7Fh
out 61h, al       ; keyboard acknowledge pulse
...
out 20h, 20h      ; PIC EOI
```

It stores key state in a small table around `07D5h + scancode`. The show driver
later checks those state bytes for exit/secret-key behavior. This direct port
handling is why the demo wants to own the machine instead of sharing polite DOS
state.

## What Each Major Part Does

At a high level:

- Startup validates VGA/memory, parses switches, neutralizes Ctrl-Break, and
  optionally initializes Sound Blaster support.
- The DAT loader reads `UFEO` blocks and expands byte-run encoded graphics and
  palette data into segment-relative work areas.
- The early visible sequence is mostly a scripted presentation: captions,
  timed waits, palette fades, picture reveals, and Ultra Force/Pandora's Box
  promises.
- The caption system uses a custom glyph renderer with nibble alignment logic
  and direct VGA mask-register writes.
- The picture system is mostly `rep movsb` into VGA memory, but timed on
  retrace and paired with palette ramps.
- The final section switches to tweaked VGA, deinterleaves planar image data,
  runs a hardware-scrolled text engine, and layers palette animation, dots,
  sprite copies, and letter/ribbon effects under scroll-text control.
- The audio system is embedded and periodically pumped from the frame-wait
  routines, so visual timing and sound servicing are coupled.

That makes `Dentro` less of a single algorithmic showcase and more of a very
PC-specific presentation engine. Its best inner loops are the pragmatic ones:
the UFEO RLE decoder, the 6-bit DAC fades, the nibble-aware caption renderer,
and the final CRTC-start scroller.

## Tiny Intro Note

The side request about `8`, `16`, `32`, `64`, `128`, and `256` byte intros is a
different corpus from Ultra Force's dentro, so I did not splice a fake canonical
set into this file.

What I verified while checking the "maybe not 8" point:

- Pouet has a list named `All 1-8b prods (MS-Dos)`:
  https://www.pouet.net/lists.php?which=310
- The list description says these are `1-8 bytetros filed under the MS-Dos 32b
  category`.
- The example `Curtain the [8]byte mono intro` is titled as an 8-byte intro, but
  Pouet's prod type is `32b`: https://www.pouet.net/prod.php?which=53065

So the clean distinction is: 1-8 byte MS-DOS bytetros do appear to exist as
Pouet-listed productions, but Pouet does not expose them as a separate `8b`
type. A proper tiny-intro analysis should pick exact productions and archive
bytes first, then dissect those bytes one by one. Without named targets, the
honest result here is a scope note, not a pretend inner-loop analysis.

## Caveats

I did not recover original labels or source, and I did not get a working
high-level trace from a live DOSBox run with confirmed Sound Blaster playback.
The address-level claims above are from the unpacked COM image and the static
`DENTRO.DAT` block map. Where I name effects, the names are inferred from
strings, hardware behavior, and surrounding code.
