Analysis model: gpt-5.5 xhigh

Optimize by Feenix/Epical - Technical Dissection

Scope

This is a static binary dissection of Optimize by Feenix/Epical, released in 1994 for the Assembly 1994 PC 4K intro competition. The Assembly 1994 result file lists it as third place in the PC 4KB intro competition, after Stoned by Dust and Spam4kb by Tobo.

Public references:

The package contains a short note granting use on the Assembly CD-ROM and a small file description identifying it as Optimize by Feenix/Epical. There are no old personal contact fields in the package.

OPTIMIZE.COM is 4095 bytes. It is a COM file that begins with a tiny RNC method 2 loader. The loader expands a 5779-byte real-mode payload over PSP:0100h and jumps back to 0100h. The expanded program uses 386 instructions, mode 13h, unchained VGA writes, CRTC start-address changes, generated sine tables, BIOS font masks, noise/smoothing passes, line-pattern sprites, and a final planar edge renderer.

Examined Files

Archive contents:

FILE_ID.DIZ       171 bytes
OPTIMIZE.COM     4095 bytes
NOTE.TXT          108 bytes

Hashes:

46d13e2d91cd3362efdff82bef9732569f4e0032d56275c2a7e6aea2da678fb7  optimize.zip
1223b42d1eced04cc1705438ef422ce9011a3a7effdb3ce0d20726f822499f5d  optimize.diz
1223b42d1eced04cc1705438ef422ce9011a3a7effdb3ce0d20726f822499f5d  FILE_ID.DIZ
5f4e6f74ee641e03f79981d942491293270261b76e06cadb86510832dacf84bf  NOTE.TXT
aa0121dd031ea73bdf29941f16717135648a8b857a08cd424e781d3f6ecd0b5b  OPTIMIZE.COM

Runtime Captures

For visual reference frames, I ran the shipped COM file under DOSBox-X with a delayed Esc key as a safety stop:

autotype -w 90 -p 0.1 esc
dx-capture /v OPTIMIZE.COM

The captured video ran for 104.832000 seconds. Three frames are useful here: the title/fire text phase, the ribbon/line-pattern renderer, and the later fractal-field phase.

At 00:15.000, the title text is visible in the red fire-text section:

Optimize sparse runtime effect sequence

Optimize runtime frame at 00:15.000 showing the red title text

At 00:35.000, the intro is in the ribbon/line-pattern section:

Optimize runtime frame at 00:35.000 showing the ribbon line-pattern visual

At 01:05.000, the later fractal-field visual is established:

Optimize runtime frame at 01:05.000 showing the orange fractal-field visual

The GIF above is a sparse effect progression assembled directly from the three 720x400 DOSBox-X frames: fire/title text, ribbon line-pattern rendering, and the later orange fractal-field phase.

Runtime-To-Code Concordance

The captured sequence is useful because the intro is not one monolithic effect. It is a scripted chain of small 4K-sized renderers, each with a distinct code path and VGA state.

The red title/fire frame at 00:15.000 is the 0ebah text/noise prelude. The entry code calls that routine five times before the main mode-13h effects:

0157  call 0e1bh             ; VGA/font/palette setup
015a  call 0ebah             ; text/noise prelude chunk 1
015d  call 0ebah             ; chunk 2
0160  call 0ebah             ; chunk 3
0163  call 0ebah             ; chunk 4
0166  call 0ebah             ; chunk 5

Those frames are not bitmap playback. 0e1bh asks BIOS for the 8x8 font pointer, 0d9fh transposes eight glyphs into the local mask at 1d60h, and 0ebah injects pseudo-random bright pixels only where that mask is non-zero. The visible fire decay comes from the four-neighbor smoothing loop at 0f46h..0f66h, while the rising base byte at 1d20h pushes the same glyph mask through brighter palette bands. That is why the letters look like volatile particles rather than a stored logo.

The growing abstract part before the ribbon capture is 0a15h driving the worker at 09bch. It reuses the generated sine-word table at 1912h; the inner loop reads three sine terms and writes duplicated pixels as a word. The changing height is the byte at 1fd6h, and the motion is just three phase words being updated after each pass:

0a98  sub [cs:1d12h],3
0aa3  add [cs:1d14h],6
0aab  sub [cs:1d16h],8

The 00:35.000 ribbon/line-pattern frame belongs to the next phase, 0c27h calling 0afch. This is the clearest still image of the effect, because the routine writes fixed 16-byte symmetric color ramps at sine-derived addresses:

0b34  mov dword es:[di],2024282ch
0b3c  mov dword es:[di+4],3034383ch
0b45  mov dword es:[di+8],3c383430h
0b4e  mov dword es:[di+0ch],2c282420h

The position is not a sprite coordinate table. 0afch derives each placement from 01d1h, 1fceh, 1fd0h, 1fd2h, and the sine table, then waits on VGA status helpers 03afh and 03bdh. The frame therefore shows a register-timed line writer, not a timer-interrupt animation. The later vertical stripe section at 0f82h uses the same phase economy in a different form: it self-patches the immediate at 1014h by 0100h every frame so the stripe function slides without an extra per-pixel variable load.

The orange fractal-field frame at 01:05.000 comes after 0860h has allocated an offscreen segment and filled it through the 0697h orbit writer and 0635h fixed-point texture copier. The code at 0697h iterates a compact complex-map formula:

0700  mov eax,[cs:1d44h]
0705  imul eax,eax
0709  sar eax,0dh
070d  mov ebx,[cs:1d4ch]
0713  imul ebx,ebx
0717  sar ebx,0dh
071b  sub eax,ebx
071e  add eax,[cs:1d3ch]

That generated segment is then reused by the CRTC/page phase at 0c7dh and by the final planar edge renderer. In other words, the orange field is both a visible effect and later source material.

The final object renderer is not visible in the three selected stills, but its pipeline explains the last major design choice in the intro. 1055h returns to mode 13h, re-enters unchained planar VGA, projects 80 table vertices from 026bh/030bh, sorts 0x4a edges by depth, and calls 13d3h for vertical textured spans. The inner span advances by 0050h, exactly 80 bytes per scanline in four-plane 320-wide VGA:

14c8  mov al,fs:[bx]
14cb  add al,[cs:1d20h]
14d0  mov es:[di],al
14d3  add di,0050h

So the runtime sequence is organized like this: BIOS-font particle text, sine-table plasma/ribbon, fixed-pattern sine lines, self-patched stripe/texture transitions, generated fractal texture, and finally a planar edge renderer that samples that generated texture. The common thread is size: almost every visible motion is a phase word, a table lookup, a VGA register trick, or a patched immediate rather than stored animation data.

RNC2 Block

The RNC block starts at file offset 0146h:

signature          RNC
method             2
unpacked size      1693h bytes
packed size        0ea7h bytes
unpacked CRC       e7f9h
packed CRC         9250h
leeway             02h
chunks             01h

After expansion, the useful COM image spans:

load address       PSP:0100h
expanded length    1693h bytes
expanded end       PSP:1793h

The expanded image also uses zeroed memory beyond the file image as BSS-like tables, with state and edge buffers around offsets 1d00h..2b00h.

COM Loader and RNC2 Depacker

The first 0x146 file bytes are loader and depacker code. Entry begins at PSP:0100h:

0100  mov si,024ah
0103  cld
0104  call read_be32_lowword
0107  add ax,0100h
010a  mov cx,ax              ; expanded end = 0100h + 1693h
010c  call read_be32_lowword
010f  mov dx,ax              ; packed size = 0ea7h
0111  add ax,si
0113  add ax,0006h
0116  mov di,ax              ; packed stream end
0118  add si,0004h
011b  lodsw
011c  xor ah,ah              ; leeway byte in AL
011e  mov bp,si              ; BP = packed data start

The read_be32_lowword helper consumes a big-endian 32-bit RNC header field but only returns the low 16 bits. That works because both the packed and unpacked sizes are below 64K.

If the packed stream overlaps the intended output area, the loader moves it upward before unpacking:

0120  mov si,di
0122  add ax,cx
0124  mov di,ax
0126  cmp di,si
0128  jbe no_move
012a  std
012b  push di
012c  dec si
012d  dec di
012e  mov cx,dx
0130  rep movsb              ; backward copy of packed bytes
0132  inc di
0133  mov bp,di              ; new packed data start
0135  pop si
0136  cld

Then it copies the 0xfa-byte depacker from 014ch to the chosen high address. The trick is the push si before the copy: the ret at 0142h jumps to the new copy.

0137  mov di,si
0139  push si
013a  mov si,014ch
013d  mov cx,00fah
0140  rep movsb
0142  ret                    ; enter relocated depacker

The relocated RNC2 depacker writes to DI = 0100h, then jumps to the expanded payload:

014c  mov si,bp
014e  stc
014f  lodsb
0150  adc al,al
0152  add al,al
0154  mov di,0100h
...
023e  mov si,0100h
0241  xor ax,ax
0243  jmp si

The bit reader is the classic compact RNC2 shape:

The hottest copy path is:

01cc  mov bl,[si]
01ce  inc si
01cf  mov bp,si
01d1  mov si,di
01d3  dec si
01d4  sub si,bx              ; source = output - distance - 1
01d6  cli
01d7  rep movsb es:[di],es:[si]
01da  sti
01db  mov si,bp

The cli/sti pair protects the overlapped copy. This is compact rather than fast, but the intro pays that cost only once at startup.

Expanded Entry and Top-Level Flow

The real payload at 0100h first resizes the DOS memory block to 0x1000 paragraphs, sets DS = ES = CS, builds sine tables, shows a five-part text prelude, and then runs the main visual phases.

0100  mov ax,4a00h
0103  mov bx,1000h
0106  int 21h                ; resize memory block
0108  push cs
0109  pop ds
010a  push cs
010b  pop es
010c  mov word [cs:2034h],0
...
0150  mov word [cs:01cfh],0
0157  call 0e1bh             ; VGA/font/palette setup
015a  call 0ebah             ; text/noise prelude chunk 1
015d  call 0ebah             ; chunk 2
0160  call 0ebah             ; chunk 3
0163  call 0ebah             ; chunk 4
0166  call 0ebah             ; chunk 5
0169  mov ax,0013h
016c  int 10h
016e  mov byte [cs:1fd2h],64h
0174  call 0a15h             ; sine-plasma/ribbon phase
0177  mov word [cs:01d1h],1
017e  call 0c27h             ; moving line-pattern phase
0181  call 0f82h             ; vertical stripe phase
0184  mov ax,0013h
0187  int 10h
0189  call 0860h             ; generated texture/scroll phase
018c  mov word [cs:1d24h],20h
0193  mov word [cs:203eh],0
019a  mov word [cs:2040h],0
01a1  call 0c7dh             ; buffered CRTC/page phase
01a4  call 1055h             ; final planar edge renderer, exits DOS

The bytes after 01a7h are data, not live fall-through. They include the text string fragments and many point/pattern tables.

Sine Table Builder

The expanded image contains an 0x81-byte quarter-wave table at 1712h. The entry code mirrors and negates it into a 512-byte signed cycle:

0113  xor bx,bx
0116  mov bp,0100h
0119  mov si,0100h
011c  mov di,0200h
011f  mov cx,0081h
0122  mov al,[cs:bx+1712h]
0127  mov [cs:bp+1712h],al
012c  neg al
012e  mov [cs:si+1712h],al
0133  mov [cs:di+1712h],al
0138  inc bx
0139  dec bp
013a  inc si
013b  dec di
013c  dec cx
013d  jne 0122h

That creates a signed lookup indexed with & 01ffh. Then the first 0x208 bytes are sign-extended to words at 1912h:

013f  mov cx,0208h
0142  mov si,1712h
0145  mov di,1912h
0148  lodsb
0149  movsx ax,al
014c  stosw
014d  dec cx
014e  jne 0148h

Most later effects use either byte sine values from 1712h or word sine values from 1912h. The table is built once, and nearly every moving offset or projected coordinate is just a masked table lookup plus an add.

VBlank Waits

Two tiny wait helpers are reused throughout:

03af  mov dx,03dah
03b2  in  al,dx
03b3  test al,08h
03b5  je  03b2h
03b7  in  al,dx
03b8  test al,08h
03ba  jne 03b7h
03bc  ret

03afh waits for vertical retrace to become active and then inactive. 03bdh does the same with bit 0:

03bd  mov dx,03dah
03c0  in  al,dx
03c1  test al,01h
03c3  je  03c0h
03c5  in  al,dx
03c6  test al,01h
03c8  jne 03c5h
03ca  ret

The intro does not install a timer interrupt. It paces visual changes by polling VGA status bits and by doing fixed-count loops.

VGA and Font Setup at 0e1b

The setup routine switches to mode 13h, seeds four state words from PIT channel 0, uploads palette ramps, obtains the BIOS 8x8 font pointer, and then changes VGA into a planar-friendly mode.

0e1b  mov ax,0013h
0e1e  int 10h
0e20  in  ax,40h
0e22  mov [cs:1d14h],ax
0e26  in  ax,40h
0e28  mov [cs:1d16h],ax
0e2c  in  ax,40h
0e2e  mov [cs:1d18h],ax
0e32  in  ax,40h
0e34  mov [cs:1d1ah],ax

The PIT reads are not for timing; they are cheap random seeds for the text prelude.

Palette upload starts at DAC index 10h and builds three 64-color ramps plus a zero tail. One ramp is red, one yellow/orange, one white/blue-ish, and the tail keeps the rest dark:

0e38  mov dx,03c8h
0e3b  mov al,10h
0e3d  out dx,al
0e3e  inc dx
...
0e71  mov cx,00c0h
0e74  xor al,al
0e76  out dx,al
0e77  loop 0e76h

Font pointer setup:

0e7f  mov ax,1130h
0e82  mov bh,03h
0e84  int 10h
0e86  mov [cs:1d1ch],es
0e8b  mov [cs:1d1eh],bp

Then it changes the mode-13h memory layout:

0e90  mov dx,03d4h
0e93  mov al,09h
0e95  out dx,al
0e96  inc dx
0e97  in  al,dx
0e98  add al,07h
0e9a  out dx,al            ; taller scanline/character-row tweak

0e9b  mov ax,0604h
0e9e  mov dx,03c4h
0ea1  out dx,ax            ; sequencer memory mode
0ea2  mov dx,03d4h
0ea5  mov ax,0014h
0ea8  out dx,ax            ; CRTC underline/location mode byte
0ea9  mov ax,0e317h
0eac  out dx,ax            ; CRTC mode byte
0ead  mov ax,0a000h
0eb0  mov es,ax
0eb2  mov dx,03c4h
0eb5  mov ax,0f02h
0eb8  out dx,ax            ; all four planes enabled

The later renderer relies on this unchained planar setup: byte offset y*80+x/4 selects a group of four pixels, and the sequencer map mask chooses the actual plane.

BIOS Font Mask Builder at 0d9f

0d9fh takes eight character codes from the text stream and converts their BIOS font rows into a local 80-byte-wide mask at 1d60h.

First it clears the mask:

0d9f  push cs
0da0  pop es
0da1  mov di,1d60h
0da4  mov cx,00a0h
0da7  xor eax,eax
0daa  rep stosd

Then it uses the saved BIOS font pointer:

0dad  mov ax,[cs:1d1ch]
0db1  mov es,ax
0db3  mov bp,0008h
0db6  mov cx,0008h          ; eight characters
0dba  movzx bx,byte [cs:si+01a7h]
0dc0  shl bx,3              ; 8 bytes per glyph
0dc3  add bx,[cs:1d1eh]

The inner loop reads one glyph row and shifts each bit into eight vertical columns:

0dcb  mov al,es:[bx]
0dce  rcl al,1
0dd0  rcl byte [cs:bp+1d60h],1
0dd5  rcl al,1
0dd7  rcl byte [cs:bp+1d61h],1
...
0dff  rcl al,1
0e01  rcl byte [cs:bp+1d67h],1
0e06  add bp,0050h          ; next text row in 80-byte stride
0e09  inc bx
0e0a  dec dx
0e0b  jne 0dcbh

This is a byte-efficient transpose: the BIOS font is row-major, but the effect wants a wide linear mask with one byte per screen-ish cell.

Text/Noise Prelude at 0eba

Each call to 0ebah displays one eight-character chunk. The five calls in the entry sequence show the title text in parts.

The routine starts by building the mask and clearing VGA memory:

0eba  push cs
0ebb  pop ds
0ebc  mov si,[cs:01cfh]
0ec1  call 0d9fh
0ec4  mov ax,0a000h
0ec7  mov es,ax
0ec9  xor di,di
0ecb  mov cx,0fa0h
0ece  xor eax,eax
0ed1  rep stosd             ; clear 64000 bytes

Then it enters a frame loop. For each of 0x280 mask positions, it either skips zero mask bytes or emits a pseudo-random brightness:

0eda  mov si,1d60h
0edd  mov di,0550h
0ee0  mov cx,0280h
0ee3  lodsb
0ee4  or  al,al
0ee6  je  skip_pixel
0ee9  mov ax,[1d14h]
0eec  mov bx,[1d16h]
0ef0  mov cx,[1d18h]
0ef4  mov dx,[1d1ah]
0ef8  add ax,bx
0efa  rol ax,cl
0efc  xor ax,dx
0efe  xchg ch,cl
0f00  add bx,cx
0f02  add dx,bx
0f04  add cx,ax
0f06  ror bx,1
0f08  sbb ax,dx
0f0a  mov [1d1ah],dx
0f0e  mov [1d18h],cx
0f12  mov [1d16h],bx
0f16  mov [1d14h],ax
0f1a  and al,1fh
0f1c  add al,[cs:1d20h]
0f21  mov es:[di],al

The random generator is not a normal LCG. It cross-mixes four 16-bit words with rotate, xor, add, and subtract, then uses the low five bits plus a rising base value.

After plotting the random glyph pixels, the routine smooths the 80-column area. This is the blur/decay inner loop:

0f2b  mov di,0000h
0f2e  mov si,di
0f30  add si,0050h
0f33  mov bp,di
0f35  add bp,004fh
0f38  mov cx,0018h
0f3b  mov dx,0050h
0f3e  mov bl,[cs:1d20h]
0f43  sub bl,05h
0f46  mov al,[di]
0f48  cmp al,bl
0f4a  ja  keep_pixel
0f4c  xor ax,ax
0f4e  mov al,[bp]
0f52  add al,[si]
0f54  add al,[di+0050h]
0f57  adc ah,0
0f5a  add al,[di+0051h]
0f5d  adc ah,0
0f60  shr ax,2
0f63  je  keep_pixel
0f65  dec ax
0f66  mov [di],al
0f68  inc di
0f69  inc bp
0f6a  inc si
0f6b  dec dx
0f6c  jne 0f46h
0f6e  dec cx
0f6f  jne 0f3bh

It averages four neighbors, subtracts one, and writes the result back. The threshold base-5 keeps bright new pixels alive while older pixels diffuse. The loop at 0f71h increments the base byte until it wraps; then 01cfh is advanced by 8 so the next call uses the next text chunk.

Sine-Plasma Phase at 0a15 and 09bc

0a15h uploads a four-ramp palette, tweaks CRTC register 9, and draws a growing sine-plasma ribbon with the worker at 09bch.

The palette contains:

The worker starts with three phase words and a screen destination:

09bc  mov bx,[cs:1d12h]
09c1  mov bp,[cs:1d14h]
09c6  mov si,[cs:1d16h]
09cb  mov di,[cs:2038h]
09d0  mov ch,[cs:1fd6h]     ; row count

For each row it takes one sine value as a row base, then walks 160 word pixels:

09d5  add bx,ffffh
09d8  add si,0005h
09db  and si,03feh
09df  mov dx,[cs:si+1912h]
09e4  push bx
09e5  push bp
09e6  mov cl,0a0h
09e8  add bx,fffch
09eb  add bp,fffeh
09ee  and bx,03feh
09f2  and bp,03feh
09f6  mov ax,[cs:bx+1912h]
09fb  add ax,dx
09fd  add ax,[cs:bp+1912h]
0a02  mov ah,al
0a04  mov es:[di],ax
0a07  add di,2
0a0a  dec cl
0a0c  jne 09e8h
0a0e  pop bp
0a0f  pop bx
0a10  dec ch
0a12  jne 09d5h

The inner loop is three sine-table reads and one word write. It writes two identical pixels at a time by copying AL into AH. The phase updates in 0a15h shift the pattern:

0a98  sub [cs:1d12h],3
0aa3  add [cs:1d14h],6
0aab  sub [cs:1d16h],8

The visible height 1fd6h rises until it reaches 100, so the ribbon grows into the screen. The second half of the routine clears 80 dwords at a moving base and decreases 1fd6h, making the shape retract.

Pattern Phase at 0c27 and 0afc

0c27h stores the current CRTC start-address low byte, sets it to zero, then calls 0afch while increasing and decreasing 01d1h.

0c35  mov dx,03d4h
0c38  mov al,13h
0c3a  out dx,al
0c3b  inc dx
0c3c  in  al,dx
0c3d  mov [cs:201ah],al
0c41  xor al,al
0c43  out dx,al
...
0c47  call 0afch
0c4b  inc word [cs:01d1h]
...
0c63  call 0afch
0c66  dec word [cs:01d1h]

0afch draws three 16-byte symmetric line patterns at positions derived from the sine word table:

0afc  mov cx,[01d1h]
0b00  call 03afh
0b03  cli
0b04  mov bx,cx
0b06  shl bx,1
0b08  sub bx,[01d1h]
0b0c  shl bx,1
0b0e  add bx,[1fceh]
0b12  and bx,03feh
0b16  mov di,[bx+1912h]
...
0b34  mov dword es:[di],2024282ch
0b3c  mov dword es:[di+4],3034383ch
0b45  mov dword es:[di+8],3c383430h
0b4e  mov dword es:[di+0ch],2c282420h

The same pattern repeats with brighter constants at 0b88h and darker mirrored constants at 0be1h. Between writes it waits through 03bdh, so the patterns are tied to display status rather than a DOS timer.

After each call it clears 80 dwords from the start of A000h and advances three phase words:

0c0c  xor eax,eax
0c0f  xor di,di
0c11  mov cx,0050h
0c14  rep stosd
0c17  add word [1fceh],6
0c1c  add word [1fd0h],4
0c21  add word [1fd2h],8

Vertical Stripe Phase at 0f82

0f82h uses the VGA PEL mask and a small palette, then fills rows with a phase-stepped vertical stripe function.

Setup:

0f82  mov dx,03c6h
0f85  mov al,0fh
0f87  out dx,al             ; PEL mask
0f88  mov dx,03d4h
0f8b  mov al,09h
0f8d  out dx,al
0f8e  inc dx
0f8f  in  al,dx
0f90  and al,70h
0f92  or  al,83h
0f94  out dx,al

The stripe worker computes a row slope from two sine lookups:

0fcd  movzx bx,cl
0fd0  shl bx,2
0fd3  add bx,[cs:1fceh]
0fd8  and bx,01ffh
0fdc  movsx ax,byte [cs:bx+1712h]
0fe2  movzx bx,cl
0fe5  shl bx,3
0fe8  add bx,[cs:1fd0h]
0fed  and bx,01ffh
0ff1  movsx bx,byte [cs:bx+1712h]
0ff7  add bx,ax
0ff9  sar bx,1

Then it fills 320 bytes. The byte written is the high byte of a fixed-point accumulator:

0ffb  push bx
0ffc  neg bx
0ffe  add bx,005ah
1001  mov ax,bx
1003  shl ax,2
1006  add ax,bx
1008  shl ax,5             ; roughly bx * 160
100b  pop bx
100c  add bx,0140h
1010  mov dx,0140h
1013  add ax,1234h         ; immediate patched each frame
1016  mov es:[di],ah
1019  inc di
101a  add ax,bx
101c  dec dx
101d  jne 1016h

At the end of every frame, the immediate at 1014h is increased by 0100h:

103d  add word [cs:1014h],0100h

That self-patched phase is why the stripes appear to slide without an extra per-pixel add source.

Texture Copy and CRTC Page Phase at 0c7d

0c7dh allocates a 64K DOS block and saves the segment at 01d5h. It then prepares an intermediate buffer using the segment allocated earlier by 0860h.

0c7d  mov ax,4800h
0c80  mov bx,1000h
0c83  int 21h
0c85  mov [cs:01d5h],ax
...
0c97  mov ax,[cs:01d3h]
0c9b  mov ds,ax
0c9d  xor di,di
0c9f  mov si,1000h
0ca2  mov dx,00c8h
0ca5  mov eax,08080808h

The loop writes a border, copies 0x40 dwords, writes another border, and repeats for 200 rows:

0cab  mov cx,0008h
0cae  rep stosd             ; left border
0cb1  mov cx,0040h
0cb4  rep movsd             ; copied texture
0cb7  mov cx,0008h
0cba  rep stosd             ; right border
0cbd  dec dx
0cbe  jne 0cabh

It then copies that prepared image to the allocated block and uses CRTC register 13h to slide the screen start. The slide loop alternates waits on 03afh and 03bdh:

0cda  mov al,13h
0cdc  out dx,al
0cdd  mov bx,0004h
0ce0  call 03afh
0ce6  mov al,[cs:201ah]
0cea  out dx,al
0ceb  mov cx,bx
0ced  call 03bdh
0cf0  loop 0cedh
0cf5  xor al,al
0cf7  out dx,al
0cf8  add bx,4
0cfb  cmp bx,018ch
0cff  jne 0ce0h

The helper at 0430h is a blocky scaler/copy routine used inside the later part of 0c7dh. It computes source and destination offsets from 1d16h, 1d1ah, 1d1ch, and a scale word at 2042h, then calls 03cbh, which expands one sampled byte into a variable horizontal run:

03e4  lodsb
03e5  shr cx,4
03e8  inc cx
03eb  rep stosb
...
0404  std
0411  lodsb
0412  shr cx,4
0415  inc cx
0418  rep stosb

After each half, it copies five dwords from the freshly written area. This gives the phase a chunky scaled texture without a general-purpose scaler.

Generator Phase at 0860

0860h sets up a generated offscreen segment and repeatedly calls 080bh, which combines a strange orbit writer at 0697h with the fixed-point texture writer at 0635h.

The phase initializes 32-bit state and allocates a 64K buffer:

086b  mov dword [cs:204ch],0
0875  mov dword [cs:1d30h],ffffc400h
087f  mov dword [cs:1d34h],ffffc7f6h
0889  mov dword [cs:1d38h],00007000h
...
090e  mov ax,4800h
0911  mov bx,1000h
0914  int 21h
0916  mov [cs:01d3h],ax
091a  mov es,ax
091e  mov cx,4000h
0921  mov eax,08080808h
0927  rep stosd

The orbit worker at 0697h iterates 32-bit values like a quadratic map:

0700  mov eax,[cs:1d44h]
0705  imul eax,eax
0709  sar eax,0dh
070d  mov ebx,[cs:1d4ch]
0713  imul ebx,ebx
0717  sar ebx,0dh
071b  sub eax,ebx
071e  add eax,[cs:1d3ch]
0724  mov [cs:1d48h],eax

0729  mov eax,[cs:1d44h]
072e  shl eax,1
0731  imul eax,[cs:1d4ch]
0738  sar eax,0dh
073c  add eax,[cs:1d40h]
0742  mov [cs:1d4ch],eax
0747  push dword [cs:1d48h]
074d  pop dword [cs:1d44h]

This is essentially a fixed-point complex iteration. It writes escape or orbit timing bytes into the offscreen segment through two advancing pointers 1d56h and 1d58h. 080bh then turns sine-derived values into parameters for the texture writer at 0635h.

The 0635h writer is an inner loop built around 32-bit fixed-point stepping:

0671  push ecx
0673  mov dh,0a0h
0675  shld ebx,ecx,10h
067a  mov bl,ch
067c  mov al,[bx]
067e  mov ah,al
0680  mov es:[di],ax
0683  add di,2
0686  add ecx,ebp
0689  dec dh
068b  jne 0675h
068d  pop ecx
068f  add ecx,esi
0692  dec dl
0694  jne 0671h

It writes 160 word pixels per row, with the source byte selected from the high parts of EBX/ECX. This is a byte-saving texture mapper: one byte read, one duplicated word write, and 32-bit accumulators for the sample position.

Final Planar Renderer at 1055 and 14fb

The final phase starts by returning to mode 13h and explicitly setting planar VGA state:

1055  mov ax,0013h
1058  int 10h
105a  mov dx,03d4h
105d  mov al,09h
105f  out dx,al
1060  inc dx
1061  in  al,dx
1062  or  al,81h
1064  out dx,al
1065  mov ax,0604h
1068  mov dx,03c4h
106b  out dx,ax
106c  mov dx,03d4h
106f  mov ax,0014h
1072  out dx,ax
1073  mov ax,0e317h
      out dx,ax
1077  mov ax,0f02h
107a  mov dx,03c4h
107d  out dx,ax

It clears memory, builds two palette ramps, and initializes camera/phase words:

10d2  mov dword [cs:1d36h],00001400h
10dc  mov dword [cs:1d2eh],00001600h
10e6  mov dword [cs:1d32h],00000000h
10f0  mov word  [cs:1d2ah],0000h
10f7  mov word  [cs:2038h],0000h

From there, 1055h is mostly a script that repeatedly calls 14fbh while moving 1d36h, 1d2eh, and 1d2ah, and while changing point-table entries. Examples:

10fe  call 14fbh
1101  sub dword [cs:1d36h],20h
1108  cmp dword [cs:1d36h],0400h
1112  jg  10feh

111b  call 14fbh
111e  mov eax,[cs:156ah]
1123  sar eax,2
1127  sub [cs:1d36h],eax
112d  mov eax,[cs:1559h]
1132  sar eax,2
1136  add [cs:1d2eh],eax
113c  dec word [cs:1d2ah]

The final renderer itself starts at 14fbh. It first derives sine and cosine from the 512-byte table:

14fb  mov bx,[cs:1d2ah]
1500  and bx,01ffh
1504  movsx eax,byte [cs:bx+1712h]
150b  mov [cs:1559h],eax
1510  mov bx,[cs:1d2ah]
1515  add bx,0080h
1519  and bx,01ffh
151d  movsx eax,byte [cs:bx+1712h]
1524  mov [cs:156ah],eax

Then it projects 80 vertices. The source coordinate tables are words at 026bh and 030bh; the projected x, y, and depth-like values go to 1d5eh, 1e26h, and 1eeeh.

1529  xor bx,bx
152b  movsx esi,word [cs:bx+026bh]
1532  mov eax,[cs:1d2eh]
1537  sar eax,6
153b  add esi,eax
153e  shl esi,1

1541  movsx ebp,word [cs:bx+030bh]
1548  mov eax,[cs:1d36h]
154d  sar eax,6
1551  add ebp,eax
1554  shl ebp,1

The next block is a compact rotate/project calculation. It stores a depth term, computes a perspective denominator in EDI, and divides to screen coordinates:

155f  imul esi
1562  neg eax
1565  mov edi,eax
1570  imul ebp
1573  add eax,edi
1576  sar eax,7
157a  mov [cs:bx+1eeeh],ax
157f  add eax,1eh
1583  mov edi,eax
...
1596  sar esi,5
159a  imul eax,esi,64h
159e  cdq
15a0  or  edi,edi
15a3  jne nonzero_z
15a5  mov edi,1eh
15ab  idiv edi
15ae  add ax,00a0h
15b1  mov [cs:bx+1d5eh],ax

15b6  mov eax,fffffa24h
15bc  cdq
15be  idiv edi
15c1  add ax,0032h
15c4  mov [cs:bx+1e26h],ax
15c9  add bx,2
15cc  cmp bx,00a0h
15d0  jb  152bh

The page-flip setup uses CRTC start address high and toggles a 0400h page bit:

15d4  mov ax,[cs:2038h]
15d8  shl ah,4
15db  mov al,0ch
15dd  mov dx,03d4h
15e0  out dx,ax
15e1  xor word [cs:2038h],0400h
15e8  mov ax,0a000h
15eb  add ax,[cs:2038h]
15f0  mov es,ax

The frame clear is also the background fill. It first clears a small leading area, then writes 50 rows of gradually increasing bytes:

15fc  xor di,di
15ff  xor eax,eax
1602  mov cx,0410h
1605  rep stosd
1608  add di,8
160b  mov eax,0c0c0c0c0h
1611  mov dx,0032h
1614  mov cx,0010h
1617  rep stosd
161a  add di,10h
161d  add eax,01010101h
1623  dec dx
1624  jne 1614h

Before drawing edges it clears a per-scanline occupancy map at 2a9ch, resets the edge count at 2a9ah, and builds a sorted edge order table at 26b2h. The sort key is the sum of the depth terms of each edge's endpoints:

1652  mov si,[cs:bx+26b2h]
1657  movzx di,byte [cs:si+01d7h]
165d  mov ax,[cs:di+1eeeh]
1662  movzx di,byte [cs:si+01d8h]
1668  add ax,[cs:di+1eeeh]
...
1692  cmp dx,ax
1694  ja  keep_order
1696  mov ax,dx
1698  push word [cs:bx+26b2h]
169d  push word [cs:bp+26b2h]
16a2  pop  word [cs:bx+26b2h]
16a7  pop  word [cs:bp+26b2h]

The draw pass walks sorted edges until either all 0x4a entries are tried or the occupancy count reaches 0090h:

16bd  cmp word [cs:2a9ah],0090h
16c4  jae done
16c6  mov bx,[cs:bx+26b2h]
16cb  movzx si,byte [cs:bx+01d7h]
16d6  movzx bp,byte [cs:bx+01d8h]
16e1  cmp si,bp
16e3  je  skip
16e5  mov ax,[cs:si+1eeeh]
16ea  add ax,[cs:bp+1eeeh]
16ef  add ax,0014h
16f2  shr ax,1
16f4  cmp ax,00a0h
16f7  jge done
16f9  mov [cs:1d20h],al     ; shade
16fd  mov word [cs:1d18h],0
1704  call 13d3h

Edge Rasterizer at 13d3

13d3h is the core final inner loop. It takes two projected points selected by 1d1ch and 1d1eh, clips them vertically, computes fixed-point x and texture steps, selects the VGA plane, and writes a vertical run.

The clipping and setup:

13d3  mov ax,[cs:01d3h]
13d7  mov fs,ax             ; texture/source segment from 0860h
13d9  mov bx,[cs:1d1ch]
13de  mov si,[cs:1d1eh]
13e3  mov ax,[cs:bx+1d5eh]  ; x0
13e8  cmp ax,[cs:si+1d5eh]  ; x1
13ed  jge return
13f1  cmp ax,0120h
13f4  jge return
13f8  cmp word [cs:si+1d5eh],20h
13fe  jl  return
1402  mov cx,[cs:si+1d5eh]
1407  sub cx,[cs:bx+1d5eh]  ; dx in screen x domain
140c  or  cx,cx
140e  jle return

It computes two per-line deltas:

1412  mov ax,[cs:si+1e26h]
1417  sub ax,[cs:bx+1e26h]
141c  cwd
141d  mov dl,ah
141f  shl ax,8
1422  idiv cx
1424  shl ax,1
1426  mov [cs:1d3ah],ax     ; y step

142a  mov ax,0ff00h
142d  xor dx,dx
142f  div cx
1431  shl ax,1
1433  mov [cs:1d3ch],ax     ; texture/source step

The plane selection is VGA-specific. The low two bits of DI pick a byte from the map-mask table at 03abh, then the byte address is divided by four:

1453  mov ax,bp
1455  xor al,al
1457  mov di,ax
1459  shr di,2
145c  add di,ax
145e  add di,[cs:2042h]
...
14b5  push di
14b6  and di,3
14b9  mov al,[cs:di+03abh]
14be  mov dx,03c5h
14c1  out dx,al
14c2  pop di
14c3  shr di,2

The vertical span itself is tiny:

14c6  xor dx,dx
14c8  mov al,fs:[bx]
14cb  add al,[cs:1d20h]
14d0  mov es:[di],al
14d3  add di,0050h          ; next scanline in planar 320-wide mode
14d6  add dx,1234h          ; patched at 14d8h
14da  mov bh,dh
14dc  dec cx
14dd  jne 14c8h

0050h is 80 bytes per scanline, i.e. 320 pixels divided by four VGA planes. Only the selected plane receives the write. The source index uses BH, fed by the high byte of DX; the immediate at 14d8h is patched from the texture/source step calculated at 1433h.

At the end of each outer scanline step, it advances the projected y and source phase:

14df  mov si,[cs:1d3ch]
14e4  add [cs:1d18h],si
14e9  add word [cs:2042h],2
14ef  add bp,[cs:1d3ah]
14f4  pop cx
14f5  dec cx
14f6  jne 1453h

The renderer avoids a general polygon fill. It draws sorted edges as vertical planar spans, with one occupancy word per scanline preventing excessive redraw. The texture source comes from the earlier generated segment, so the final object is both geometric and texture-driven.

Exit Path

After the final scripted sequence, 1055h clears the planes, fades DAC entry 0 down through a short loop, returns to text mode, and exits:

139d  mov dx,03c5h
13a0  mov ax,000fh
13a3  out dx,al
13a4  mov ax,0a000h
13a7  mov es,ax
13ab  xor eax,eax
13ae  mov cx,3e80h
13b1  rep stosd
...
13c9  mov ax,0003h
13cc  int 10h
13ce  mov ax,4c00h
13d1  int 21h

There is no DOS timer hook to restore, which is one reason the shutdown path is short.

Why It Fits the 4K Class

The design is size-oriented in several ways:

Optimize is not a single trick intro. It is a chain of small, byte-aware kernels: RNC expansion, table generation, BIOS-font masking, random diffusion, sine table raster loops, CRTC slides, generated texture buffers, and a planar edge renderer.