Analysis model: gpt-5.5 xhigh

Plan-B by Sonic PC - Technical Dissection

Release year: 1993

Plan-B is Sonic PC's MS-DOS 100K intro from Assembly 1993. The Assembly 1993 PC intro results place it sixth, after Eclipse, Debut, Tangle, Locomotion, and Motion. That makes it the next entry in the Assembly 1993 "best intros" path after the already-covered top-five set.

The binary's own text credits Mik and Jaz for the intro, Mellow-D for the music, Cybelius for help with the tune, and Ranx for artwork. The embedded greeting text also thanks Tran for the protected-mode header and Daredevil for released GUS information. I deliberately do not reproduce the old personal greeting list from the binary.

Sources:

Offset notation:

This is a static binary pass with a short DOSBox-X sanity run. Names for visual parts are inferred from code shape, tables, data flow, and visible strings.

Archive Identity

The scene.org archive is tiny:

PLANB.EXE       65,389 bytes
FILE_ID.DIZ         44 bytes

FILE_ID.DIZ contains only:

Plan-B by Sonic PC
Presented at Assembly'93

Hashes used for this pass:

1e05c8eac725af4655d1b92250e2c76fe1441ddeccd4435b8130c9b5fdd6e768  planb.zip
4ef5250871bf1ffd321b98ef389ecf58952835634d85e432b36c5df4cee1c88a  planb.diz
b9fed2e36d7ee73cbc8b0fbd22f6b600cb1f11d73034b9c37518b390cec7940c  asm93-results.txt
4ef5250871bf1ffd321b98ef389ecf58952835634d85e432b36c5df4cee1c88a  FILE_ID.DIZ
a06c7bf0a8850470906498b951e5b9ae9fbf88e6b65b6c2041f0a7055a5d6a99  packed PLANB.EXE

The original executable is an MZ file and file identifies the payload as DIET compressed. UNP 4.12 gives the exact packing diagnosis:

DOS file size:   65389
file-structure:  executable (EXE)
EXE part sizes:  header 32 bytes, image 65357 bytes, overlay 0 bytes
processed with:  DIET V1.45f <L>
new file size:   170493

The expanded executable hash:

d486678aeaaa334e9b8bda48093e8d6b2ca4e056c7323e55c80ebe38a3929ad6  UNP-expanded PLANB.EXE

Expanded MZ Layout

After DIET expansion the file is a single MZ image with no overlay:

file size:          170,493 bytes
computed MZ image:  170,493 bytes
header bytes:           512 bytes
load image bytes:   169,981 bytes
overlay bytes:            0 bytes
relocations:              16
initial CS:IP:      0000:027c
initial SS:SP:      2980:1000
entry file offset:  1,148

The load image hash:

854a41e08f5b65231cc83f8daf85f5b20aae40a3ad5dda9251866c15b343deb0  planb-load.bin

Useful landmarks:

expanded+00000  protected-mode shell error strings
expanded+0027c  MZ entry
expanded+016a0  "Sonic Music System    by Mik/Sonic"
expanded+02392  "ULTRASND"
expanded+06124  greeting text block, deliberately summarized here
expanded+08298  visible intro text script
expanded+1c661  embedded ProTracker module start
expanded+1ca99  module "M.K." signature

The MZ relocation table has only sixteen entries. Most of the code uses flat 32-bit offsets patched by the protected-mode shell instead of a heavily relocated 16-bit program image.

Runtime Check

A short DOSBox-X run used:

gus=true
gusbase=240
gusirq=7
gusdma=3
ULTRASND=240,3,3,7,7

The log reaches PLANB.EXE, switches to VGA graphics sizing, and does not print one of the shell's DOS error strings. The headless run did not produce a useful capture before the timeout prompt, so the visual analysis below stays grounded in the expanded binary rather than screenshots.

High-Level Map

The intro is not a conventional C/Pascal DOS program. The expanded file starts with a compact protected-mode shell, then a self-contained sound system, then visual code and data:

00000..0169f  protected-mode shell, error strings, DPMI/VCPI/raw paths
016a0..03fc0  Sonic Music System, GUS/SB/PAS paths, MOD parser, IRQ code
03fcd..03ff2  VGA retrace wait helpers
05f03..063de  planar VGA setup, buffers, greeting/font path, palette helpers
06575..07c29  object/dot/curve sections with sine tables and palette fades
07e38..08801  pseudo-random stars, text script decoder, star/text scheduler
08802..08c77  object setup and scanline span/edge helper
0a500..0a8da  later picture/window effect and copy loops
1c661..2873c  embedded ProTracker module
2873d..299fc  4,800-byte trailer after the parsed MOD data

The most important design choice is that the program keeps its own timing and rendering paths. There are no external assets and no INT 10h mode setup call in the expanded load image. VGA programming is direct port I/O, and sound is direct hardware setup with a GUS-first path.

The following map is generated from the expanded-binary ranges above. It is not a runtime screenshot; it is a compact view of the released file's structure after DIET expansion:

Plan-B expanded executable architecture map

Protected-Mode Shell

The shell's entry at expanded+027c starts in real mode, disables interrupts, uses CS as DS, then calls a small DOS memory helper before computing flat bases from incoming segment values:

027c  cli
027d  cld
027e  push cs
027f  pop  ds
0280  call 0217
0283  mov  ax,es
0285  movzx eax,ax
0289  shl  eax,4
028d  mov  [0e24],eax
0294  mov  eax,0
029a  shl  eax,4
029e  mov  [0e28],eax
02b5  mov  ebx,0e1h
02bb  shl  ebx,4
02bf  mov  [0e2c],ebx
02d7  add  [0c43],ebx

The literal 0xe1 << 4 is the load-image paragraph base for the protected part. The shell adds it into stored pointers and computes the heap/top-of-memory distance from the MZ stack segment. This is why later code can use flat offsets such as 0x4474, 0x7071, and 0x96cc after the switch.

The next branch probes for a 32-bit DPMI host:

0318  mov  ax,1687h
031b  int  2fh
031d  or   ax,ax
031f  je   0600      ; DPMI path
0323  call 01d0      ; 386/V86-style checks
0326  jae  09f6
032a  call 0238
032d  mov  ax,4300h
0330  int  2fh
0332  cmp  al,80h
0334  je   0879      ; XMS/A20 path
0338  jmp  0cd8      ; raw/VCPI path

The binary includes error strings for missing 386, not enough low or extended memory, V86 mode, failed A20, non-32-bit DPMI, descriptor exhaustion, and incompatible VCPI PIC mappings. That matches the code: it has separate raw, VCPI, and DPMI transitions rather than depending on one extender.

The shell has its own PIC remap helper at expanded+033b. It saves the master and slave masks from ports 21h and A1h, sends ICW1 to 20h and A0h, writes caller-provided vector bases from BX, sends cascade/mode bytes, then restores the masks:

033b  in   al,0a1h
033d  mov  ch,al
033f  in   al,21h
0341  mov  cl,al
0343  mov  al,11h
0345  out  20h,al
0347  out  0a0h,al
034f  mov  al,bl
0351  out  21h,al
0353  mov  al,bh
0355  out  0a1h,al
035d  mov  al,04h
035f  out  21h,al
0361  mov  al,02h
0363  out  0a1h,al
036b  mov  al,01h
036d  out  21h,al
036f  out  0a1h,al
0371  mov  al,cl
0373  out  21h,al
0375  mov  al,ch
0377  out  0a1h,al
0379  ret

The A20 helper at expanded+037a tries the fast A20 gate at port 92h, then falls back to the keyboard gate through ports 64h and 60h. The verification test writes through GS:0010 and checks whether it aliases FS:0000:

037a  xor  ax,ax
037c  mov  fs,ax
037e  dec  ax
037f  mov  gs,ax
0381  call 03dd          ; alias test
0384  je   03be
0386  in   al,92h
0388  or   al,02h
0390  out  92h,al
0392  call 03dd
0395  je   03be
0397  call 03ac          ; wait for keyboard input buffer clear
039c  mov  al,0d1h
039e  out  64h,al
03a5  mov  al,0dfh
03a7  out  60h,al

The protected-mode landing stub at expanded+040b loads selectors, installs a 32-bit stack, adds the runtime base delta, then jumps through DI:

040b  mov  ax,0028h
040e  mov  ds,ax
0410  mov  al,18h
0412  mov  gs,ax
0414  mov  al,10h
0416  mov  es,ax
0418  mov  fs,ax
041a  mov  ss,ax
041c  mov  esp,1000h
0422  add  esp,[0ef5]
042a  jmp  di

From this point onward most meaningful routines are 32-bit code with direct hardware I/O.

Sonic Music System

The string Sonic Music System by Mik/Sonic at expanded+016a0 marks a large self-contained player. It is not just a MOD playback stub. It includes:

212c  sound init entry
2282  command-line parser for speed and card mode
2509  ProTracker pattern row converter
257b  sample loader/copy path
2641  GUS DRAM byte upload loop
26a8  timer table setup
2876  sample-volume table builder
28da  GF1 status/data write helper
291a  GF1 DRAM location write helper
2950  GF1 DRAM location read helper
2bb0  card detection and setup dispatcher
3d55  GUS voice current-position programming
3d79  GUS voice frequency/period programming
3d9c  GUS voice loop start/end programming
3dde  GUS voice volume helper
3f15  IRQ service path

The init at expanded+212c calls setup functions, selects a timer rate, and falls back into a silent or simple path if no supported device is found:

212c  call 23b6
2131  jb   5294
2137  call 2bb0
213c  jb   5294
2142  cmp  byte [11eb],1
2149  jne  2192
214b  mov  edx,0
2150  mov  eax,0f4240h       ; 1,000,000
2155  mov  ebx,[11fe]        ; requested rate
215b  sar  ebx,1
215d  add  eax,ebx
215f  mov  ebx,[11fe]
2165  div  ebx
216e  mov  eax,0f4240h
2173  div  ebx
2175  mov  [11fe],eax

The constants show it is deriving hardware timer divisors from a requested playback frequency. The -s command-line option accepts either raw Hertz or a small value that gets shifted by 10, then clamps into a usable range:

22c5  call 239b
22ca  cmp  eax,2ch
22cd  ja   22d2
22cf  shl  eax,0ah       ; small option means kilohertz-like value
22d2  cmp  eax,0fa0h     ; lower bound
22d9  cmp  eax,0ac40h    ; upper bound
22e0  mov  [11fe],eax

The card-mode option is -c0 through -c4:

22e7  cmp  al,'c'
22eb  lods al
22ec  cmp  al,'0'
22f0  cmp  al,'4'
22f4  sub  al,'0'
22f6  mov  [11eb],al

MOD Pattern Converter

The embedded module is normal ProTracker-style four-channel data. The converter at expanded+2509 rewrites each 4-byte packed MOD event into an internal 3-byte row event:

2509  mov  ecx,[121a]
250f  mov  eax,[0ace]
2514  add  eax,043ch
251a  mov  [121a],eax
251f  mov  esi,eax
2523  add  ecx,edi
2525  mov  [2f11],ecx

252b  lodsw
252d  xchg al,ah
252f  push ax
2531  mov  dx,ax
2534  lodsw
2536  xchg al,ah
2538  push ax
253a  and  dh,0f0h
253d  shr  ah,4
2540  add  ah,dh
2542  mov  al,ah
2544  stosb             ; sample number

Then it converts a ProTracker period into a compact note index by comparing it against a 37-entry period table at expanded+122c:

2549  push dx
254b  and  ax,0fffh
254f  mov  cx,0025h
2553  mov  ebx,122ch
2558  mov  dl,0
255a  cmp  ax,[ebx]
255d  jae  2566
255f  add  ebx,2
2562  inc  dl
2564  loop 255a
2566  mov  al,dl
2568  stosb             ; note index

Finally it stores the effect/parameter word:

2569  pop  ax
256b  and  ah,0fh
256e  xchg al,ah
2570  stosw             ; command and parameter
2572  cmp  edi,[2f11]
2578  jb   252b

This is a classic MOD-player preprocessing trick: the hot playback interrupt no longer needs to decode ProTracker nibbles or search periods. It receives a small sample id, a period index, and a packed effect word.

GUS Detection And DRAM Upload

The GUS path scans GF1 bases from 210h upward in steps of 10h and performs write/read tests through the GF1 DRAM location registers:

2be7  mov  word [11ca],0210h
2bf0  mov  dx,[11ca]
2bf7  add  dx,0103h
2bfc  mov  ax,004ch
2c00  out  dx,al
2c01  add  dx,2
2c05  xchg al,ah
2c07  out  dx,al
2c25  mov  al,0aah
2c27  call 291a
2c2c  mov  ebx,0100h
2c31  mov  al,055h
2c33  call 291a
2c38  xor  ebx,ebx
2c3d  call 2950
2c57  cmp  ax,00aah
2ca3  add  word [11ca],10h
2cab  cmp  word [11ca],0270h
2cb4  jb   2bf0

The location write helper at expanded+291a programs the low and high pieces of a GF1 DRAM pointer, then writes one data byte:

291a  push dx
291c  push ax
291e  mov  dx,[11ca]
2925  add  dx,0103h
292a  mov  al,43h
292c  out  dx,al
292d  inc  dx
292f  mov  ax,bx
2932  out  dx,ax
2934  dec  dx
2936  mov  al,44h
2938  out  dx,al
2939  add  dx,2
293d  ror  ebx,16
2940  mov  al,bl
2942  out  dx,al
2943  add  dx,2
2947  pop  ax
2949  out  dx,al
294a  rol  ebx,16
294d  pop  dx
294f  ret

The sample upload loop at expanded+2641 writes a run of bytes to GUS DRAM, updating the high GF1 location register when the low 16 bits wrap:

2641  mov  ebx,[182d]      ; current GUS DRAM pointer
2647  mov  ecx,[120a]      ; byte count
264d  cli
264e  push ecx
264f  mov  dx,[11e0]
2656  mov  al,44h
2658  out  dx,al           ; high pointer register select
2659  add  dx,2
265d  mov  eax,ebx
265f  shr  eax,16
2665  out  dx,al
266a  mov  al,43h
266c  out  dx,al           ; low pointer register select
266d  inc  dx
266f  mov  ax,bx
2672  out  dx,ax
2676  add  dx,4
267a  lodsb
267b  out  dx,al           ; sample byte
2680  add  bx,1
2684  jae  2697
2686  inc  bp
2688  mov  al,44h
268a  out  dx,al
2692  out  dx,al           ; refresh high pointer after wrap
2697  loop 266a
269a  mov  ebx,[120a]
26a1  add  [182d],ebx
26a7  ret

This is not a DMA path; it is direct byte streaming to GF1 memory. The code keeps interrupts disabled around the transfer because half-updated GF1 pointer registers would make the upload land in the wrong spot.

GUS Voice Programming And IRQ

The voice helpers write GF1 registers for current position, period/frequency, loop start/end, volume, and voice mode:

3d55  mov  dx,[11e0]
3d5c  mov  al,0ah
3d5e  out  dx,al
3d5f  inc  dx
3d61  mov  eax,[esi+14h]
3d64  shr  eax,7
3d67  out  dx,ax
3d6b  mov  al,0bh
3d6d  out  dx,al
3d73  shl  eax,9
3d76  out  dx,ax

The loop start/end writer is the same pattern with GF1 registers 02h..05h:

3d9c  mov  dx,[11e0]
3da3  mov  al,02h
3da5  out  dx,al
3da8  mov  eax,[esi+2ch]
3dab  shr  eax,7
3dae  out  dx,ax
3db2  mov  al,03h
3db4  out  dx,al
3db7  mov  eax,[esi+2ch]
3dba  shl  eax,9
3dbd  out  dx,ax
3dc1  mov  al,04h
3dc3  out  dx,al
3dc6  mov  eax,[esi+04h]
3dc9  shr  eax,7
3dcc  out  dx,ax
3dd0  mov  al,05h
3dd2  out  dx,al
3dd5  mov  eax,[esi+04h]
3dd8  shl  eax,9
3ddb  out  dx,ax

The IRQ path at expanded+3f15 reads the GF1 status port, acknowledges voice interrupt state through GF1 register 8fh, and sends EOI to both PICs:

3f15  pusha
3f18  mov  edx,[11d2]
3f1e  in   al,dx
3f24  test al,04h
3f26  je   3fa3
3f28  mov  dx,[11e0]
3f2f  mov  al,45h
3f31  out  dx,al
3f43  or   byte [3100],04h
3f50  mov  al,[0ad3]
3f55  cmp  [3103],al
3f5d  mov  [3103],al
3f62  mov  bx,[11f4]
3f70  mov  al,46h
3f72  out  dx,al
3f77  mov  al,bl
3f79  out  dx,al
3f9e  call 3452
3fa9  mov  dx,[11e0]
3fb0  mov  al,8fh
3fb2  out  dx,al
3fb7  in   al,dx
3fb8  mov  al,20h
3fba  out  0a0h,al
3fbc  out  20h,al
3fbe  popa
3fbf  sti
3fc0  iret

The player therefore uses both frame-side calls and interrupt-side servicing: the visual sections repeatedly call expanded+221a, while the hardware IRQ keeps GUS playback state moving.

Embedded Module

The module starts at file offset 0x1c861, or expanded+0x1c661. The M.K. signature is exactly 1080 bytes later:

module start file offset:  0x1c861
module start load offset:  0x1c661
"M.K." file offset:        0x1cc99
"M.K." load offset:        0x1ca99

The title field begins with Sudden rainfalls, and the sample-name text credits Mellow-D and Cybelius. Parsed module facts:

song length:       23 order entries
pattern count:     24 patterns
sample data bytes: 23,200
computed MOD size: 48,860 bytes
trailer after MOD:  4,800 bytes

The used order list is:

1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 16, 15, 9, 10, 11, 12, 17, 18, 19, 20, 21, 22, 23

The non-empty sample lengths are small enough to fit the 100K intro budget:

sample  2:   694 bytes
sample  4: 2,270 bytes
sample  5: 2,528 bytes
sample  6: 7,414 bytes
sample  8: 3,086 bytes
sample  9: 1,880 bytes
sample 10:   600 bytes
sample 11: 4,728 bytes

The module is not simply appended as a DOS overlay. It sits in the expanded load image, so the player can refer to it through flat offsets after the shell enters protected mode.

VGA And Timing Primitives

Plan-B does not use BIOS video calls in the expanded load image. Its retrace helpers poll VGA input status register 3dah:

3fcd  mov  dx,03dah
3fd4  in   al,dx
3fd5  test al,08h
3fd7  jne  3fd4
3fd9  in   al,dx
3fda  test al,08h
3fdc  je   3fd9
3fde  ret

3fdf  mov  dx,03dah
3fe3  in   al,dx
3fe4  test al,08h
3fe6  je   3fe3
3fe8  ret

3fe9  mov  dx,03dah
3fed  in   al,dx
3fee  test al,08h
3ff0  jne  3fed
3ff2  ret

These provide wait-for-edge and wait-for-state variants. The visual scheduler uses them before DAC uploads, page changes, and fade loops.

The planar VGA setup at expanded+5f03 switches chain/odd-even style bits and enables all planes:

5f03  call 3fdf
5f08  mov  dx,03c4h
5f0c  mov  al,04h
5f0e  out  dx,al
5f0f  inc  dx
5f11  in   al,dx
5f12  and  al,0f7h
5f14  or   al,04h
5f16  out  dx,al
5f17  mov  dx,03ceh
5f1b  mov  al,05h
5f1d  out  dx,al
5f20  in   al,dx
5f21  and  al,0efh
5f23  out  dx,al
5f26  mov  al,06h
5f28  out  dx,al
5f2b  in   al,dx
5f2c  and  al,0fdh
5f2e  out  dx,al
5f2f  mov  dx,03c4h
5f33  mov  ax,0f02h
5f37  out  dx,ax

It also sets CRTC registers 14h and 17h so the layout behaves like a flat 320-wide planar target:

5f39  mov  dx,03d4h
5f3d  mov  al,14h
5f3f  out  dx,al
5f42  in   al,dx
5f43  and  al,0bfh
5f45  out  dx,al
5f48  mov  al,17h
5f4a  out  dx,al
5f4d  in   al,dx
5f4e  or   al,40h
5f50  out  dx,al

The runtime stores the visible VRAM base as expanded+4474, with expanded+5d40 and expanded+5d44 holding adjacent screen pages:

5f56  mov  eax,0a0000h
5f5c  sub  eax,[001c]
5f62  mov  [4474],eax
5f67  mov  [5d40],eax
5f6c  add  eax,03e80h
5f71  mov  [5d44],eax

Palette Helpers

The simplest palette upload is expanded+6385: write DAC index 0, output 24 RGB bytes, then write DAC index 16 and output another 24 bytes.

6385  mov  al,00h
6387  mov  dx,03c8h
638b  out  dx,al
638c  inc  dx
638e  mov  ecx,18h
6393  rep  outsb
6395  dec  dx
6397  mov  al,10h
6399  out  dx,al
639a  inc  dx
639c  mov  ecx,18h
63a1  rep  outsb
63a3  ret

expanded+63a4 is a greyscale mapper. For each entry it reads three source bytes, keeps the maximum channel value, and writes it three times to DAC data port 3c9h:

63a4  push ax
63a6  call 3fdf
63ad  mov  dx,03c8h
63b1  out  dx,al
63b2  inc  dx
63b4  lodsw
63b6  cmp  al,ah
63b8  jb   63bc
63ba  xchg ah,al
63bc  lodsb
63bd  cmp  al,ah
63bf  jae  63c3
63c1  xchg ah,al
63c3  out  dx,al
63c4  out  dx,al
63c5  out  dx,al
63c6  loop 63b4
63c8  ret

expanded+63c9 is the straight fade/upload helper: convert ECX palette entries to ECX * 3 bytes and stream them with rep outsb.

Greeting Text Blitter

The greeting part at expanded+608d clears a 200-byte line table, uploads a small palette, selects VGA plane 3 through the Sequencer Map Mask, then stamps a 40-column text block twice:

608d  mov  eax,0
6092  mov  ecx,0c8h
6097  rep  stosb
6099  mov  esi,5545h
609e  call 6385
60a3  cli
60a4  mov  dx,03c4h
60a8  mov  al,02h
60aa  out  dx,al
60ab  mov  al,08h
60af  out  dx,al
60b0  sti

The inner glyph loop is column-major. Each non-space source character selects a 12-byte font slice from the font table at expanded+dcf0, then writes one byte per scanline with a 40-byte pitch:

60d3  mov  ebp,0dcf0h     ; font
60d8  mov  esi,5314h      ; text
60dd  mov  edx,28h        ; 40 columns
60e2  lodsb
60e3  or   al,al
60e5  je   6120
60e7  cmp  al,20h
60e9  je   610f
60eb  sub  al,61h
60f2  lea  eax,[eax+eax*2]
60f5  shl  eax,2          ; 12 bytes per glyph
60f8  mov  ecx,0ch
60fd  mov  bl,[ebp+eax]
6101  mov  [edi],bl
6103  add  edi,28h        ; next scanline
6106  inc  eax
6107  loop 60fd
6109  sub  edi,01e0h      ; back to top row
610f  inc  edi            ; next column
6110  dec  edx
6111  jne  60e2
6118  add  edi,0208h      ; next text row block
611e  jmp  60e2

The data following this routine contains the greeting block. The same font blitter pattern is reused later for the visible intro text script.

Sine Dot Field

The setup at expanded+7080 and expanded+71d9 builds a warp table from the 16-bit sine table at expanded+31fd, then allocates per-row offsets and per-depth lookup tables.

The first builder computes four banks of 256 entries. For each entry it samples sine values, divides by a depth-like EBP, stores two word coordinates, and a combined packed offset:

7131  mov  ebx,4
713b  mov  ecx,100h
7140  add  ebp,[624a]
7146  dec  ecx
7147  add  cl,bl
7149  add  cl,40h
714c  movsx eax,word [ecx*2+31fdh]
7154  sar  eax,5
715a  movsx esi,word [ecx*2+31fdh]
7162  sar  esi,5
7167  cdq
7168  idiv ebp
716e  stosw
7170  lea  esi,[esi+esi*4]
7174  cdq
717b  idiv ebx
717e  stosw
7180  shl  eax,6
7183  lea  eax,[eax+eax*4]
7186  add  eax,esi
7188  stosd
718d  loop 7146

The plotting loop at expanded+7360 is the actual dot field. It advances four phase bytes, samples the sine table four times, combines those samples into a base pixel offset, then adds pattern offsets from the precomputed table:

7392  mov  esi,[4bfa]
7398  movzx ecx,byte [674f]
739f  movzx eax,word [674d]
73a6  add  [4bfa],eax
73ac  movzx edx,byte [6759]
73b3  add  dl,[6761]
73bf  movsx ebx,word [edx*2+31fdh]
73c7  mov  eax,ebx
73c9  and  ax,0f800h
73cd  shl  eax,5
73d0  sar  ebx,5
73d3  and  bl,0c0h
73d6  lea  ebx,[ebx+ebx*4]

More sine samples perturb EAX and EBX, then each dot is bounds checked and plotted by adding 2 to the target pixel:

7459  lodsd
745a  add  eax,edx
745c  cmp  eax,0c80000h
7461  ja   7469
7463  cmp  ax,0140h
7467  jb   7476
7469  add  esi,4
746c  loop 7459

7476  lodsd
7477  add  eax,ebx
7479  add  byte [eax],2
747c  loop 7459

The companion loop at expanded+7696 uses row-offset table expanded+6397 and a byte lookup selected by a phase byte. It clears the old dot, selects a new target, and increments it:

76a2  mov  esi,[638f]
76a8  mov  ebp,[6397]
76ba  mov  ecx,[63a3]
76c0  movzx ebx,byte [6759]
76c7  add  bl,[6761]
76d3  movsx eax,word [ebx*2+31fdh]
76db  sar  eax,9
76de  mov  dl,al
7711  mov  dl,[696b]
7717  movzx ebx,byte [675b]
771e  add  bl,[6762]
772a  movsx eax,word [ebx*2+31fdh]
7732  sar  eax,9
7735  add  dl,al
7756  lodsw
7758  movsx ebx,byte [edx]
775b  movsx eax,ax
775e  add  eax,[4474]
7764  add  eax,[ebp+ebx*4]
7768  inc  byte [eax]
776a  loop 7711

The visual result is a moving field made from sine-driven offsets rather than per-dot perspective math. The expensive divides are pushed into setup tables; the frame loop is mostly byte phases, table reads, and one-byte pixel updates.

Star And Text Section

The text script begins at expanded+8298. It contains row numbers followed by text, command bytes, and an 0xff terminator. Visible strings include welcome!, sonic presents, an intro, by mik and jaz, the music/art credits, and the stars on the screen! line.

The pseudo-random generator at expanded+7e38 is a 16-bit state mixer:

7e38  push bx
7e3a  push cx
7e3c  mov  ax,[7065]
7e42  mov  bx,[7067]
7e49  add  ax,bx
7e4c  rol  ax,cl
7e4f  xor  ax,dx
7e52  xchg ch,cl
7e54  add  bx,cx
7e57  add  dx,bx
7e5a  add  cx,ax
7e5d  ror  bx,1
7e60  sbb  ax,dx
7e63  mov  [7065],ax
7e69  mov  [7067],bx
7e70  pop  cx
7e72  pop  bx
7e74  ret

The star setup at expanded+7e91 creates 4096 star records. It repeatedly calls the generator until the x and y values fall inside the wanted ranges, then stores a byte intensity and builds a depth-projection table:

7ea2  push ebp
7ea3  call 7e38
7ea8  cmp  bx,0208h
7ead  jb   7ebd
7eaf  sub  bx,0208h
7eb4  add  [7065],bx
7ebb  jmp  7ea8
7ebd  sub  bx,0104h
7ec2  cmp  ax,0190h
7ec6  jb   7ed5
7ec8  sub  ax,0190h
7ecc  sub  [7065],ax
7ed3  jmp  7ec2
7ed5  sub  ax,00c8h
7ed9  mov  [707b],ax
7edf  mov  [7079],bx

The depth loop calculates projected x and y. On success it stores a pointer into the star table; on failure it stores zero:

7f15  movsx eax,word [707b]
7f1c  shl   eax,6
7f20  idiv  ebp
7f22  add   eax,64h
7f25  cmp   eax,0c8h
7f2a  jb    7f39
7f2c  mov   word [edi],0
7f31  add   edi,2000h
7f37  jmp   7f85

7f45  movsx eax,word [7079]
7f4c  shl   eax,6
7f50  idiv  ebp
7f52  add   eax,0a0h
7f57  cmp   eax,0140h
7f5c  jb    7f6c
7f6c  sub   eax,0a0h
7f74  add   eax,ebx
7f77  add   eax,7da1h
7f7c  mov   [edi],ax
7f7f  add   edi,2000h

The renderer at expanded+80cc reads the current star pointer table, clears the previous star unless it is a protected text pixel, fetches the next projected offset, and writes a small brightness:

80cc  mov  esi,[7075]
80d2  mov  ecx,[707d]
80d8  movzx ebx,byte [7249]
80df  mov  ah,bl
80e1  shl  ebx,0dh
80e4  add  ebx,[7071]
80ea  mov  edx,[4474]
80f0  mov  edi,[ebp]
80f3  cmp  byte [edi],80h
80f6  jae  80fb
80f8  mov  byte [edi],0
80fb  movzx edi,word [ebx]
80fe  add  edi,edx
8100  cmp  byte [edi],80h
8103  jb   810a
8105  mov  edi,0
810a  mov  [ebp],edi
810d  lodsb
810e  add  al,ah
8110  and  al,7fh
8112  shr  al,1
8114  mov  [edi],al
8116  add  ebx,2
8119  add  ebp,4
811c  loop 80f0
811e  xor  byte [7249],40h
8125  ret

That 0x80 threshold is important. Text pixels use high values, so the star clear pass does not erase them. The star field and text are drawn into the same screen but use the high bit as a cheap ownership mask.

The text decoder at expanded+8149 handles row commands and character mapping. Bytes under 0x1f set the current x/y or wait counters. Printable text is mapped into a custom font index, then stored in a 20-column text page:

8149  cmp  al,1fh
814b  jae  8169
814d  movzx ebx,al
8150  mov  [73d8],ebx
8156  movzx ebx,ah
8159  mov  [73dc],ebx
8162  shr  eax,10h
8169  cmp  al,1fh
816d  mov  [7718],ah

8190  mov  ah,0
8192  cmp  al,3ah
8196  mov  al,7dh
8198  cmp  al,39h
819c  cmp  al,31h
81a0  sub  al,13h
81c2  sub  al,61h
81c4  mov  edi,[73dc]
81ca  lea  edi,[edi+edi*4]
81cd  shl  edi,2
81d0  add  edi,[73d8]
81d6  shl  edi,1
81d8  add  edi,[73e0]
81de  mov  [edi],ax
81e1  inc  dword [73d8]

The glyph plotter at expanded+8233 walks the text page. It draws only glyphs whose age counter is under eight, which creates the animated text reveal:

8233  movzx esi,byte [7249]
823a  and  esi,1
823d  shl  esi,1
823f  add  esi,[73e0]
8245  movzx edi,byte [7249]
824c  and  edi,1
824f  shl  edi,4
8252  add  edi,[4474]
8258  inc  edi
8259  mov  ecx,78h
8265  lodsw
8267  cmp  ah,08h
826a  jae  827a
826c  movzx ebx,ah
826f  shl  ebx,5
8272  call 81f4        ; masked glyph stamp
8277  inc  byte [esi-1]
827a  add  edi,20h
827d  add  esi,2
8280  dec  byte [7488]
8286  jne  8295
8288  mov  byte [7488],0ah
828f  add  edi,17c0h
8295  loop 8265

The scheduler at expanded+8527 ties stars and text together. It first uploads a ramp palette, then for each frame:

854d  call 3fd0          ; wait retrace edge
8552  inc  dword [639f]  ; frame counter
8558  call 221a          ; sound tick/service
855d  mov  ebp,[7069]
8563  call 80cc          ; star bank A
8568  mov  ebp,[706d]
856e  call 80cc          ; star bank B

Before text starts, it wipes symmetric horizontal bands from the top and bottom:

85a6  mov  edi,[639f]
85ac  lea  edi,[edi+edi*4-015eh]
85b3  shl  edi,7
85bb  add  edi,[4474]
85c1  add  edi,3201h
85c7  mov  ecx,0a0h
85cc  rep  stosw
85d0  neg  edi
85d2  add  edi,[4474]
85d8  add  edi,0c6c1h
85de  mov  ecx,0a0h
85e3  rep  stosw

Once the text path is active, it advances the script every fourth frame:

85e8  call 8233
85ed  test byte [7249],03h
85f4  jne  8630
85f6  mov  esi,[7649]
85fc  cmp  esi,7648h
8602  je   8642
8613  cmp  byte [7718],0
861a  je   8624
861c  dec  byte [7718]
8624  inc  dword [7649]
862a  lodsd
862b  call 8149
8630  inc  byte [7249]
8636  and  byte [7249],7fh
863d  jmp  854d

Near the end, it derives a four-digit decimal number from the current star count slot, writes it into the text script bytes around expanded+768e, fades the DAC to white, and reuses the same two-bank star renderer for the final message.

Span And Polygon Helper

The span helper starts with an edge-table generator at expanded+8ac5. It takes two y endpoints in BX and CX, a table pointer in DI, and a row count in BP. The routine computes a fixed-point slope by dividing the x delta by the y delta, then stores one word per row:

8ac5  cmp  bx,cx
8ac8  jne  8ad1
8aca  inc  byte [7d30]
8ad0  ret

8ad1  shl  bp,2
8ad5  add  di,4486h
8ada  sub  cx,bx
8ae0  mov  bx,cx
8ae3  neg  bx
8ae6  mov  si,cx
8ae9  shl  esi,11h
8aec  rol  ebx,10h
8aef  rol  ecx,10h
8af2  sub  cx,bx
8af5  jns  8a8c

The negative-slope and positive-slope loops differ only in how the fractional carry is corrected:

8b20  mov  [di+4486h],bx
8b26  add  ebx,eax
8b28  js   8b2c
8b2a  sub  ebx,esi
8b2c  sub  di,4
8b30  jne  8b20

The triangle routine at expanded+8b41 reads three vertex indexes, looks up three 32-bit vertex records, sorts them by y, and builds edge tables for all three sides:

8b49  mov  edi,921ah
8b50  mov  ebx,[edi+eax*4]
8b54  mov  ecx,[edi+eax*4]
8b58  mov  edx,[edi+eax*4]
8b5b  cmp  bx,cx
8b5e  jg   8b62
8b60  xchg ecx,ebx
8b62  cmp  cx,dx
8b65  jg   8b69
8b67  xchg edx,ecx
8b69  cmp  bx,cx
8b6c  jg   8b70
8b6e  xchg ecx,ebx

It stores the total y span and the upper split, then calls the edge routine three times:

8b70  mov  [7d26],dx
8b77  mov  ax,bx
8b7a  sub  ax,dx
8b7d  mov  [7d24],ax
8b83  mov  ax,bx
8b86  sub  ax,cx
8b89  mov  [7d2a],ax
...
8bdd  call 8ac5
8be7  call 8ac5
8bf1  call 8ac5

The span drawer at expanded+8c2e consumes two edge values per scanline, orders left/right, clips zero-length spans to one pixel, and ORs a mask byte into the target buffer:

8c2e  lodsw
8c30  mov  edx,[9628]      ; pitch/width
8c36  shr  edx,1
8c38  movsx ebx,ax
8c3b  add  ebx,edx
8c3d  lodsw
8c3f  movsx ebp,ax
8c42  add  ebp,edx
8c44  cmp  ebp,ebx
8c46  jg   8c4a
8c48  xchg ebx,ebp
8c4a  push edi
8c4b  add  edi,ebx
8c4d  sub  ebp,ebx
8c4f  cmp  ebp,0
8c52  jne  8c59
8c54  mov  ebp,1
8c59  mov  al,[4bfe]
8c5e  or   [edi],al
8c60  inc  edi
8c61  dec  ebp
8c62  jne  8c5e
8c64  pop  edi
8c65  add  edi,[9628]
8c6b  sub  esi,8
8c6e  dec  word [7d24]
8c75  jne  8c2e

This is a compact filled-polygon core. The edge table is word-based, the fill is byte-mask OR rather than texture sampling, and pitch comes from the active window width. Later routines reuse it for small shape overlays in the final section.

Later Window Copy Effect

The larger block beginning at expanded+a500 sets up another work buffer, clears the DAC, builds a shaded background, fades a 768-byte palette toward a target palette, then repeatedly copies a moving window from a work buffer to the visible page.

The background build uses compact run lengths from expanded+96bc: for each run it writes 0xa0 words with the current shade in the high byte:

a597  mov  esi,96bch
a59c  mov  ebx,10h
a5a1  lodsb
a5a2  movzx ebp,al
a5a5  mov  eax,10h
a5aa  sub  eax,ebx
a5ac  mov  ah,al
a5ae  mov  ecx,0a0h
a5b3  rep  stosw
a5b6  dec  ebp
a5b7  jne  a5ae
a5b9  dec  ebx
a5ba  jne  a5a1

The palette fade compares each current DAC byte against a target byte and bumps it upward by one until the 63-frame fade is done:

a5d5  mov  esi,8be0h
a5da  mov  edi,88e0h
a5df  mov  ecx,300h
a5e4  lodsb
a5e5  cmp  [edi],al
a5e7  je   a5eb
a5e9  inc  byte [edi]
a5eb  inc  edi
a5ec  loop a5e4
a5ee  call 3fdf
a5f3  mov  esi,88e0h
a5f8  mov  ecx,300h
a5fd  mov  dx,03c8h
a603  out  dx,al
a604  inc  dx
a606  rep  outsb
a608  call 221a
a60d  dec  ebp
a60e  jne  a5d5

The main window copy uses 0x140 as the physical line pitch and copies rows from the work buffer to the visible buffer, trimming the right edge when the window would run off-screen:

a802  mov  esi,[9618]
a808  mov  ebp,[962c]
a80e  mov  ebx,ecx
a810  shr  ebx,1
a812  mov  edx,[9620]
a818  add  edx,ebx
a81a  cmp  edx,0136h
a820  jb   a82c
a822  sub  edx,0134h
a828  sub  ecx,edx
a82e  cmp  edi,[4474]
a834  ja   a840
a836  add  edi,0140h
a83c  add  esi,ecx
a840  push ecx
a841  rep  movsb
a843  pop  ecx
a844  add  esi,edx
a846  add  edi,0140h
a84c  sub  edi,ecx
a84e  dec  ebp
a84f  jne  a82e

The final copied top/bottom bands use the same 320-byte pitch and short rep movsb spans. The routine is careful not to repaint the whole frame when only a moving window or strip has changed.

Why It Fits In 100K

Plan-B spends bytes on a serious runtime shell and a real music system, so the visual side is byte-conscious:

It is a dense intro: not as immediately famous as the top-three Assembly 1993 intros, but technically it is a strong protected-mode/GUS/VGA package for a sixth-place 100K entry.