Analysis model: gpt-5.5 xhigh, sol high
Last edited: 2026-08-25
Friday the 13th by Crack Rat of T.B.S. - Technical Dissection
friday.zip appears in the Hornet 1991 demo index as Friday the 13th by Crack Rat of T.B.S.. The ZIP member timestamp in the copy I examined is from
2023, so I treat that as mirror/archive metadata and use the Hornet 1991
catalog location as the release-year evidence.
Release year: 1991.
This is closer to a cracktro / sound-demo splash than to a multipart demoscene demo. It fades in a 320x200 VGA horror-head/title picture, tries to enter a large Sound Blaster-driven section, and exits with its own Sound Blaster warning when that path is not accepted. The interesting code is still substantial: self-file resource loading, CRC-checked compressed overlays, palette fades, a small animated point/sprite routine, and a Sound Blaster DMA mixer/player path.

The front-page card uses this contact sheet directly. I did not convert it into a GIF because the published runtime evidence is one composite sheet from the short title/failure-path capture, not separate same-size frame files from the long Sound Blaster section.
Sources
- Hornet 1991 demo index: https://ftp.scene.org/mirrors/hornet/demos/1991/00_index.txt
- Scene.org archive: https://ftp.scene.org/mirrors/hornet/demos/1991/friday.zip
- Scene.org file page: https://files.scene.org/view/mirrors/hornet/demos/1991/friday.zip
Archive
The examined archive is friday.zip from the Hornet mirror:
friday.zip 193155 bytes
sha256 2a46f17e6ebf54e93992e213ec07587231d75c22bb8575efcba197c519eba1b5
ZIP contents:
friday.exe 196217 bytes 2023-04-29 18:31 mirror/archive timestamp
Hashes:
26530a5e509ff6ce6b8f6ee4d1cf675af409ac53d18eed16aa36d5321db61203 friday.exe
f57e64679d9410587622bbd8cee1ccffce5a8e242aaeaf5ab7f2e8aa4d2deb19 UNP-expanded FRIDAY.EXE
The shipped file is a packed MZ executable with a large appended overlay. UNP restores the loader/code image well enough for static disassembly, but the original packed executable is the safer runtime target because the program opens and seeks inside its own executable.
Runtime Capture And Timestamps
The runtime frames were captured from the original packed friday.exe, not from
the UNP-expanded copy:
DOSBox-X version 2026.01.02 Commit 59915c1
capture command dx-capture /v FRIDAY.EXE
capture format MPEGTS H.264 + AAC
video stream 640x400 capture of 320x200 mode 13h content
capture duration 6.363500 seconds
timing zero start of the capture command
emulated CPU normal core, 9000 cycles
Two Sound Blaster configurations were tried:
default attempt sb16, base 220h, IRQ 7, DMA 1
compat attempt sbpro2, base 220h, IRQ 7, DMA 1,
enable speaker=true, pic unmask irq=true, irq hack=2
Both runs reached the same visible result: the title picture fades in, then the program exits through its own Sound Blaster-required text path. The compatibility run proves DOSBox-X did apply the startup IRQ-unmask option, but this capture still did not enter the long sound section. That makes the runtime evidence shorter than the static code would suggest.
Observed frame points:
00:00.100 black start; only low-level background/capture noise visible
00:00.300 white flash / full DAC wash
00:00.600 horror-head picture appears through a pale fade
00:00.900 title text and right-side credit text become readable
00:01.200 picture and title continue fading toward normal contrast
00:01.500 almost full contrast; red title text is visible at left
00:02.000 full title: head graphic, `Friday the 13th` text, right credit stack
00:02.500 same title screen, stable picture and palette
00:03.000 final title hold before exit
00:04.000 text-mode Sound Blaster warning, Brain Slayer attribution line
00:05.500 same warning page, waiting during DOSBox-X post-exit delay
I also tried the UNP-expanded executable as a runtime target. It displayed the same title picture, then printed the program's read/seek error path. That is consistent with a self-reading overlay loader that is sensitive to file layout. The UNP copy is useful for disassembly; the original executable is the runtime reference.
FFmpeg frame extraction from DOSBox-X's H.264 transport stream emitted decode warnings, a recurring artifact of this capture backend in this workspace. The sampled stills are visually coherent.
Runtime-To-Code Concordance
The contact sheet covers the short title/failure path, not the unobserved long
Sound Blaster section. The 00:00.300 white wash and the 00:00.600 pale
picture line up with the startup sequence that selects mode 13h at
046Ch..046Eh, uploads the initial 256-entry DAC table through 063Ch, copies
the MAING picture into A000:0000 through the 0692h full-screen copy, and
then enters the palette fade at 05C6h.
The 00:00.900 through 00:03.000 title frames are the same 64,000-byte
screen held while the palette settles. The overlay loader found the MAING
record through the five-byte tag scanner at 0228h, the G graphics path
copied 7D00h words at 0373h..0376h, and the final A000 transfer at
0692h..06ABh makes the visible horror-head/title card direct framebuffer art,
not a generated scene.
The contact sheet does not show the ANIMA point/RLE section running for long,
but the visible startup path has already loaded that material before the sound
module decision. The relevant routines are bounded here: the A000
screen-fragment interpreter starts at 001Eh, the small point-set updater is
entered at 0D56h, and the actual erase/plot pass begins at 0DE2h. Those
offsets explain the static animation support present in the binary without
pretending the failed DOSBox-X SB run exposed a long animation timeline.
The 00:04.000 and 00:05.500 text-mode warning frames map to the program's
own failure exit, not to DOSBox text outside the demo. The sound module entry at
04EDh falls through to the restore/message path when the required SB setup is
not accepted; the visible cleanup is 055Bh restoring the original video mode
followed by the 04DCh text-print path. This is why the original packed EXE is
the runtime reference while the UNP copy is only used for static offsets.
Original And UNP-Expanded MZ Layout
The original executable is mostly overlay:
original file size 196217 bytes
MZ image size 7790 bytes
MZ header size 32 bytes
loaded image 7758 bytes
overlay size 188427 bytes
relocations 0
initial CS:IP 01CE:000E
initial SS:SP 0352:0080
entry raw file offset 1D0Eh
UNP expands the resident image and preserves the same overlay size:
UNP file size 201455 bytes
MZ image size 13028 bytes
MZ header size 80 bytes
loaded image 12948 bytes
overlay size 188427 bytes
relocations 11
initial CS:IP 0000:0404
initial SS:SP 19BC:E000
entry raw file offset 454h
The offsets below use the UNP-expanded load-image convention unless stated
otherwise: 0000:0404 means offset 0404h in the restored load image, not the
raw file offset after the MZ header.
One caveat matters. The restored program contains relocations for segment constants. At runtime the instruction that looks like:
0407 mov ax,0246h
040a mov ds,ax
really means "set DS to the data segment relative to the program load base".
When I refer to DS:01DD, its static location in the load image is
0246h * 16 + 01DDh = 263Dh.
Startup Flow
The restored entry point is compact and readable:
0404 mov sp,E000h
0407 mov ax,0246h
040a mov ds,ax
0412 call 0131h ; open this EXE and compute overlay start
041b call 06B1h ; CPU generation probe
042b mov ax,1A00h
042e int 10h ; VGA display-combination query
046c mov al,13h
046e call 0545h ; mode 13h and partial clear
0472 mov word [01F2],0100h
0478 call 063Ch ; upload 256-entry DAC table
047b ... ; load MAING resource
04ad call 0692h ; copy 64000 bytes to A000
04b6 call 05C6h ; fade palette
04ba ... ; load ANIMA and MOD1 resources
04c8 call 04EDh ; sound/animation module initialization
04cb call 0577h ; short palette/script loop
04ce call 0000h ; module callback; offset 0 is initially RET
04d2 call 055Bh ; restore original video mode
04d5 call 017Fh ; close self-file handle
04d8 int 21h,4C00h
The program first checks CPU class and stores a boolean at DS:01F6. The CPU
routine is a classic flags/shift test:
06B1 result 0086h, 0186h, 0286h, 0386h, or 2030h
041E test AX >= 0286h enables the sound path flag at DS:01F6
After that it calls BIOS video function AX=1A00h. If AL != 1Ah, or if the
display combination does not pass the code's BL test, it prints one of the
VGA/monitor failure messages and exits. The visible intro therefore assumes VGA
mode 13h, not EGA fallback.
Self-File Overlay Loader
The loader does not use a separate data file. It finds its own executable name, opens it with DOS, computes the overlay start from the MZ page/count fields, and then scans tagged records inside the appended data.
The name lookup starts in the process environment block:
00bf push es
00c4 push word [0000h] ; saved PSP-ish segment
00c8 pop ds
00c9 push word [002Ch] ; PSP environment segment
00cd pop ds
00ce mov cx,1000h
00d1 xor si,si
00d3 lodsb ; walk environment strings
00d4 or al,al
00d6 jz 00DAh
00d8 loop 00D3h
...
00eb lea di,[0008h] ; copy program path into DS:0008
The open/overlay-size setup follows:
0131 call 00BFh
0134 mov ax,3D00h ; open read-only
0137 mov dx,0008h
013a int 21h
013e mov [0002h],ax ; file handle
0145 mov ah,42h ; seek to offset 2 in MZ header
014a mov dx,0002h
014f int 21h
0153 mov cx,0004h
0159 mov ah,3Fh ; read cblp/cp
015f int 21h
0163 mov cx,[0004h] ; cblp
0167 mov bx,0200h
016c mov ax,[0006h] ; cp
016f dec ax
0170 mul bx
0172 add ax,cx
0174 adc dx,0
0177 mov [0006h],dx
017b mov [0004h],ax ; overlay file offset
The tag dispatcher at 0228h is driven by five-byte resource IDs. The initial
load order is stored at relocated DS:01DD, static image offset 263Dh:
MAING ANIMA MOD1 M
In practice the first three IDs are the important resources:
overlay+00000h MAING
overlay+01E92h ANIMA
overlay+06DB3h MOD1
0228h reads a desired five-byte ID from the resource-name string, seeks back to
the overlay start, then repeatedly reads 12-byte segment headers and either
loads the matching record or seeks to the next one:
0229 lodsw ; first two ID bytes
022a mov dx,ax
022c lodsw ; next two ID bytes
022d mov cx,ax
022f lodsb ; fifth ID byte
0230 mov [011Ah],al
0241 call 01A9h ; seek to overlay base
0248 call 01BEh ; read 12-byte segment header
0254 cmp al,[si+04h] ; fifth byte matches?
0259 jne next_record
0271 mov bx,[si+00h] ; first two ID bytes in record
0273 mov ax,[si+02h] ; next two ID bytes in record
0276 cmp ax,cx
027a cmp bx,dx
027e cmp al,4Dh ; M record?
0285 cmp al,41h ; A record?
028c cmp al,47h ; G record?
The code dispatches by fifth letter:
M multi-segment/module style load
A allocation/list load; builds a segment pointer list ending FFFFh
G graphics block; copies metadata and 64000 bytes
The G path is the simplest: after locating and optionally decompressing the
block, it copies exactly 7D00h words into the destination buffer:
0332 pop es
0333 mov ax,es:[020Ah] ; source segment
0337 mov ds,ax
0339 mov si,es:[0208h] ; source offset
033e add si,0015h ; skip graphics-block metadata
0341 lodsw ; metadata into DS:01FA
...
035b mov di,es:[020Eh]
0362 rep movsb ; copy per-block side data
0367 mov di,[0208h]
0370 mov es,ax
0373 mov cx,7D00h
0376 rep movsw ; 64000-byte screen-sized copy
This is why the title picture appears even in the short runtime captures: the
MAING graphics block loads and gets copied to A000:0000 before the later
Sound Blaster decision.
CRC And Compressed Chunk Reader
The overlay blocks are not raw-only. The loader has a CRC table builder and two data paths: stored chunks and compressed chunks.
07D4h builds a 256-entry CRC table at DS:0014. The polynomial is the usual
little-endian form of EDB88320h, split across DX and AX:
07dd mov bp,00FFh
07e0 mov cx,0008h
07e3 mov dx,bp
07e5 xor ax,ax
07e7 shr ax,1
07e9 rcr dx,1
07eb jae no_xor
07ed xor dx,8320h
07f1 xor ax,EDB8h
07f6 stosw
07f7 xchg ax,dx
07f8 stosw
07f9 dec bp
0799h updates that CRC over a byte span. It rotates the previous CRC state
through CX:DX, xors the next byte into the low part, and uses the 4-byte table
entry selected by BL * 4:
07a0 mov cx,[041Ah]
07a4 mov dx,[041Ch]
07a8 mov di,0014h
07b1 lodsb
07b4 xor bl,cl
07b6 mov cl,ch
07b8 mov ch,dl
07ba mov dl,dh
07bc mov dh,bh
07be shl bx,1
07c0 shl bx,1
07c2 xor cx,[bx+di]
07c4 xor dx,[bx+di+02h]
The decompressor is at 0871h..0C7Eh. It is an LZ/Huffman-style reader with
small generated decode tables, not a plain RLE copy. The front half builds
tables from compact run-coded code-length data:
0952 call 0937h ; read a byte from the compressed stream
0958 cmp ax,cx ; length must fit the expected symbol count
095e inc cx
095f mov di,0C62h
0964 call 0937h
0967 stosb ; collect packed length/run byte
096f lodsb
0972 shr bl,4 ; upper nibble -> repeat count class
0976 inc bx
0979 and al,0Fh ; lower nibble -> value class
097b inc ax
097c sub dx,bx
0980 rep stosb ; expand table values
The table constructors populate several fixed decode areas:
3DA2h / 3FA2h / 41A2h distance-related tables
43A2h / 45A2h / 47A2h
49A2h
4BA2h / 4CA2h symbol and bit-count tables
4DA2h..5022h code-length/order tables
The hot inflate loop starts at 0B06h. It maintains:
SI/BP compressed input cursor and remaining bytes in the 0800h refill buffer
DI current output position in the sliding window
CH/DX bit-buffer state
5742h last decoded back-reference distance
5274h flush size, either 1000h or 2000h depending on block flags
5278h retained window size
The bit reader at 0BE3h subtracts the requested bit count from CH. If not
enough bits remain, it shifts the current DX, refills DH from [SI], and
calls 0C34h/0C53h when the 0800h input buffer is exhausted:
0BE3 sub ch,cl
0BE5 jae have_bits
0BE7 neg ch
0BE9 sub cl,ch
0BEB shr dx,cl
0BED dec bp
0BF0 call 0C34h ; refill if BP underflowed
0BF3 mov dh,[si]
0BF5 inc si
0BF8 mov ch,08h
0BFA sub ch,cl
0BFC xor bh,bh
0BFE shr dx,cl
0C00 mov bl,dl
The literal path decodes a symbol and writes it directly:
0B42 test dl,dl
0B44 jz extended_literal
0B46 mov al,[bx+43A2h]
0B4A cmp al,0FFh
0B4C je long_literal_table
0B4E mov cl,[bx+44A2h]
0B52 call 0BE3h
0B55 stosb ; one literal byte to output window
The match path decodes a distance to 5742h, decodes a length, and then copies
from already produced output:
0B8C mov cl,[bx+4CA2h]
0B90 mov bl,[bx+4BA2h]
0B95 shl bx,cl
0B98 or bl,ah
0B9A mov [5742h],bx
...
0BC5 xchg ax,cx ; CX = match length
0BC6 push si
0BC7 mov si,di
0BC9 sub si,[5742h]
0BCD dec si
0BCE rep movsb ; overlapping LZ copy is intentional
0BD1 pop si
When the output pointer reaches 3C62h, the decompressor flushes a slice to
the final destination and slides the window:
0BD2 cmp di,3C62h
0BD6 jb next_token
0C07 mov cx,[5274h]
0C0B mov dx,[5F64h]
0C0F call 0C74h ; CRC update + output copy
0C12 mov di,0C62h
0C15 mov si,[5F64h]
0C19 add si,[5274h]
0C1D mov cx,[5278h]
0C21 sub si,cx
0C23 add cx,0140h
0C27 rep movsb ; preserve sliding history
0C2A sub di,[5274h]
This is a real compressed resource system. The title graphic, animation data, and large sound payload are not just flat byte arrays appended to the EXE.
VGA And Palette Path
The visible title is mode 13h:
0545 mov ah,00h
0547 int 10h ; AL is desired mode, 13h at the call site
054A mov ax,A000h
054D mov es,ax
054F xor di,di
0552 xor ax,ax
0554 mov cx,36B0h
0557 rep stosw ; initial partial clear
The palette upload routine is the canonical VGA DAC triplet loop:
063C push ds
063E mov cx,[01F2h] ; number of palette entries
0642 lea si,[0210h] ; RGB triplets
0649 mov dx,03C8h
064C out dx,al ; start at color 0
064D inc dx ; 03C9h data port
064E lodsb
064F out dx,al ; red
0650 lodsb
0651 out dx,al ; green
0652 lodsb
0653 out dx,al ; blue
0654 loop 064Eh
The full title image copy is even more direct:
0692 push ds
0695 mov ax,[020Ah]
0698 mov es,ax
069A mov di,[0208h]
069E mov si,[0204h]
06A2 mov ax,[0206h]
06A5 mov ds,ax
06A8 mov cx,7D00h
06AB rep movsw ; 7D00h words = 64000 bytes
The fade-in at 05C6h first copies the target palette from 0210h to 0510h
while zeroing the live palette. It then repeatedly uploads the current palette
and nudges each component toward the target:
05CC mov cx,[01F2h]
05D2 shl ax,1
05D4 add cx,ax ; entries * 3
05D7 lea si,[0210h] ; target
05DB lea di,[0510h] ; saved target copy
05DF movsb ; save one target byte
05E1 mov byte [si],00h ; zero live byte
...
05F0 call 063Ch ; upload live palette
05FA mov al,[si]
05FC inc al
05FE mov [si],al ; brighten all live bytes for a white-ish wash
...
0616 lea si,[0510h] ; target copy
061B call 0627h ; decrement live bytes until target reached
The helper at 0627h is one-sided: if the current byte differs from target, it
decrements the current byte. The preceding increment phase deliberately drives
the palette above the final values, then this helper walks it back down.
That matches the capture: black, white wash, pale picture, normal contrast.
There is also a tiny retrace wait at offsets 000Ch and 0015h:
000C mov dx,03DAh
000F in al,dx
0010 and al,08h
0012 jz 000Fh ; wait until vertical retrace
0015 mov dx,03DAh
0018 in al,dx
0019 and al,08h
001B jnz 0018h ; wait until retrace ends
Several loops call this instead of relying on timer interrupts, which keeps palette stepping and screen updates tied to VGA beam timing.
Secondary Screen/Animation RLE
Offset 001Eh is a small graphics unpacker that writes to A000:0000. It is
not the big overlay inflater; it is a fast screen-fragment/RLE interpreter for
already loaded animation blocks.
It reads a segment pointer from a list at DS:0810, wraps when it sees FFFFh,
and then interprets byte commands:
001E mov ax,A000h
0022 mov es,ax
0025 mov si,[0810h]
002A lodsw
002B mov [0810h],si
002F cmp ax,FFFFh
0034 lea si,[0812h] ; restart list if needed
003E mov ds,ax
0040 xor si,si
0042 xor di,di
004F mov cl,[si]
0051 inc si
0052 jcxz fill_run
0054 or cl,cl
0056 jl negative_cmd
0058 rep movsb ; literal run
The command forms are:
positive count copy that many literal bytes to A000
zero next byte is count, following byte is fill value
negative not 80h skip count-80h pixels by advancing DI
80h + positive word long skip
80h + negative word long literal/fill family
The long copy/fill paths align on word boundaries before using rep movsw or
rep stosw, then mop up an odd byte:
0089 test si,0001h
008F movsb ; align source if needed
0091 shr cx,1
0095 rep movsw
009B rep movsw
009D movsb ; odd tail
00A3 lodsb ; fill byte
00A4 mov ah,al
00A6 test di,0001h
00AC stosb ; align dest if needed
00AE shr cx,1
00B2 rep stosw
00B8 stosb ; odd tail
This is a small but well-shaped VGA blitter: branch at command granularity, then use string instructions for the inner copy/fill work.
Title Animation / Point Plotter
The title screen is mostly static, but the restored code contains a small
animation routine. 0D19h runs a far callback, then calls 0D51h. The latter
selects one of four point sets and bounces a vertical screen offset between
0000h and 3200h in steps of 0140h:
0D56 mov bx,cs:[007Fh] ; point-set index 0..3
0D5C shl bx,1
0D5E mov di,7D0Ah
0D61 add di,cs:[0099h] ; moving vertical offset
0D66 add di,cs:[bx+0091h]
0D6D mov dx,6571h
0D75 shl ax,1
0D79 add dx,bx ; previous-position list
0D7B mov si,0600h
0D7E add si,cs:[bx+0089h]
0D83 call 0DE2h
...
0DAD sub word cs:[0099h],0140h
0DC5 add word cs:[0099h],0140h
0DCC cmp word cs:[0099h],3200h
The actual point plotter at 0DE2h is two phase:
- Clear the pixels recorded on the previous visit to this point set.
- Test exactly
3Ch(60) new points and record every accepted address for that set's next visit.
Clear phase:
0DE2 mov ax,A000h
0DE5 mov es,ax
0DEA mov si,dx ; previous-position list
0DEE lodsw
0DEF cmp ax,FFFFh
0DF2 je plot_new
0DF4 mov di,ax
0DF6 xor al,al
0DF8 stosb ; erase old pixel
0DF9 jmp 0DEEh
Plot phase:
0DFD mov cx,003Ch
0E00 xor bx,bx ; byte offset into previous-position list
0E04 xor ah,ah
0E06 mov al,[si] ; source byte
0E08 mov cl,03h
0E0A shr ax,cl
0E0C mov cl,06h
0E0E shl ax,cl ; (byte >> 3) * 64
0E10 add di,ax
0E12 mov cl,02h
0E14 shl ax,cl ; plus *256, total *320
0E16 add di,ax
0E18 mov al,es:[di]
0E1B or al,al
0E1D jne skip_pixel
0E20 mov si,dx
0E22 add si,bx
0E24 mov [si],di ; remember pixel address
0E26 add bx,2
0E2A mov al,0FFh
0E2C stosb ; draw white point
0E2F inc di ; next x position
0E30 add si,8 ; next source record
0E33 loop 0E02h
0E39 mov word [si],FFFFh
The y coordinate is encoded cheaply: ((byte >> 3) * 320) is computed as
(byte >> 3) * 64 + (byte >> 3) * 256. The x coordinate comes from the running
DI. The renderer avoids overdraw by checking whether the destination pixel is
zero before writing FFh.
The four-way rotation changes the cleanup interpretation. CS:007Fh advances
0,1,2,3,0..., while the tables at 0081h, 0089h, and 0091h select a
different saved-address list, source slice, and x origin for each set. A set is
therefore erased on its next turn, four visual callbacks later; these are not
the previous global frame's pixels. Each call consumes 60 source bytes from 60
eight-byte records, spanning 480 bytes of its source slice. The vertical offset
walks 0000h..3200h by 0140h, so one direction has 41 inclusive positions.
If Pold is the number accepted on this set's prior visit and Pnew is the
number accepted now, one invocation has this exact traffic:
source-byte reads 60
VGA destination tests 60 reads
VGA cleanup writes Pold bytes
VGA new-point writes Pnew bytes
saved-address writes Pnew words + one FFFFh sentinel word
accepted points 0..60
maximum steady-call VGA writes 120 bytes (Pold = Pnew = 60)
address-list capacity 61 words = 122 bytes per set
The zero test means all 60 candidates are always evaluated, but only points over black background enter the cleanup list. This bounds both the inner loop and its sparse-update benefit without assuming a particular unseen frame.
This is not a general sprite engine. It is a very specific "small bright points over a title image" routine with four independently aged cleanup lists, so it only rewrites accepted pixels when each set moves.
Sound Blaster Path
The startup text says this is a Sound Blaster music demo and that the sound is the largest part of the intro. The code supports that claim: there is a real DSP reset/probe, IRQ-vector handling, 8-bit DMA setup, and sample mixing.
The visible startup reaches 04EDh after loading ANIMA and MOD1:
04ED in al,60h
04EF mov [01F9h],al
04F2 mov word [01F2h],0080h
04FE lea si,[0812h]
0502 mov [0810h],si
0506 cmp word [01F6h],0 ; CPU >= 286?
050B je fail
050E mov ax,032Ah
0511 mov ds,ax
0513 mov word [675Ah],1
0519 mov word [675Ch],0
051F mov word [675Eh],1
0528 lcall 00CBh:0932h ; module/sound initializer
052F jae ok
0531 call 03DDh ; free allocated resource segments
0534 jmp 04DCh ; restore mode and print SB failure text
The capture exits through that failure path. However, the resident code around
0F69h..146Ah shows what the accepted path is meant to do.
The base-port probe tries common Sound Blaster bases:
1424 mov word cs:[0013h],0220h
142B call 1047h
142E je 146Ah
1430 mov word cs:[0013h],0230h
1437 call 1047h
143A je 146Ah
143C mov word cs:[0013h],0240h
1443 call 1047h
1446 je 146Ah
1448 mov word cs:[0013h],0250h
144F call 1047h
1452 je 146Ah
1454 mov word cs:[0013h],0260h
145B call 1047h
145E je 146Ah
1460 mov word cs:[0013h],0210h
1467 call 1047h
146A ret
1047h is the DSP reset test. It writes 1 then 0 to base+6 and waits up to
16 read attempts for AAh from the DSP read port:
1047 mov dx,cs:[0013h]
104C add dl,06h
104F mov al,01h
1051 out dx,al
1052 in al,dx ; short delay by repeated reads
1056 sub al,al
1058 out dx,al
1059 mov bl,10h
105B call 1028h ; wait for DSP data ready, read base+0Ah
105E cmp al,0AAh
1060 je found
1062 dec bl
1064 jne 105Bh
1066 mov ax,0002h
1069 stc
106C xor ax,ax
106E or ax,ax ; sets ZF for caller
IRQ detection appears immediately after the base probe. The tiny stubs at
146Bh, 1473h, 147Bh, and 1483h set CS:0015 to IRQ 2, 3, 5, or
7, acknowledge the PIC, read DSP status at base+0Eh, and iret:
146B mov byte cs:[0015h],02h
1473 mov byte cs:[0015h],03h
147B mov byte cs:[0015h],05h
1483 mov byte cs:[0015h],07h
1489 mov al,20h
148B out 20h,al
148D mov dx,cs:[0013h]
1492 add dx,000Eh
1495 in al,dx
1496 iret
The vector hook at 11ADh then installs the real DMA refill handler on
IRQ + 8. The apparent address mismatch is segmentation, not generated or
self-modified code: this player runs in segment 00CBh relative to the load
image, so live CS:0478 maps to raw image offset
00CB0h + 0478h = 1128h, exactly where the handler disassembles:
11AD mov al,cs:[0015h]
11B1 add al,08h
11B3 mov ah,35h
11B5 int 21h ; get old vector
11C6 mov dx,0478h ; live CS offset; raw load-image offset 1128h
11CD add al,08h
11CF mov ah,25h
11D1 int 21h ; set vector
11D9 mov ah,01h
11DB shl ah,cl
11DD not ah
11DF in al,21h
11E1 and al,ah
11E3 out 21h,al ; unmask selected IRQ
The DMA IRQ handler at 1128h is a classic single-cycle 8-bit SB refill:
1128 pusha
1129 mov al,20h
112B out 20h,al ; EOI
112D mov dx,cs:[0013h]
1132 add dx,000Eh
1135 in al,dx ; acknowledge DSP interrupt
1136 mov ax,cs:[0000h] ; DMA page/address/count prepared by mixer
113A mov bx,cs:[0002h]
113F mov cx,cs:[0004h]
1144 mov al,05h
1146 out 0Ah,al ; mask DMA channel 1
1148 mov al,ah
114A out 83h,al ; page register
114C mov al,bl
114E out 02h,al ; base low
1150 mov al,bh
1152 out 02h,al ; base high
1168 mov al,cl
116A out 03h,al ; count low
116C mov al,ch
116E out 03h,al ; count high
1170 mov al,01h
1172 out 0Ah,al ; unmask channel 1
1182 mov al,14h
1184 out dx,al ; DSP single-cycle DMA output command
1192 mov al,cl
1194 out dx,al
11A2 mov al,ch
11A4 out dx,al
11A5 mov byte cs:[0007h],0FFh
11AB popa
11AC iret
The whole handler is only 133 bytes. A normal no-wait path executes 53
instructions, performs 11 port writes, and performs at least four port reads
(one DSP IRQ acknowledge plus three DSP-ready polls). Every extra ready-poll
iteration adds one in, one or, and one conditional jump. Its programming
body at 1136h..11A4h is 111 bytes and is byte-for-byte identical to the
initial-start body at 1363h..13D1h; startup and refill therefore cannot drift
into subtly different DMA/DSP recipes.
There is an off-by-one asymmetry in that shared recipe. The value N from
CS:0004h is written directly to the 8237 DMA count register, whose hardware
meaning is N + 1 bytes. The code then decrements CX and sends N - 1 to
the DSP, whose single-cycle command means N samples. With the normal
N = 0200h block, the programmed DMA window is 513 bytes while the DSP asks
for 512 samples. The DSP terminates the transfer after those 512 samples, so
the extra DMA count is normally latent rather than an extra audible byte.
The direct DSP setup routine sends speaker-on and time-constant commands:
0FF5 wait base+0Ch not busy
1002 mov al,0D1h ; speaker on
1004 out dx,al
1012 mov al,40h ; set time constant
1014 out dx,al
1022 mov al,cs:[0017h]
1026 out dx,al
CS:0017h is D3h. For the original Sound Blaster time-constant formula,
that is approximately 1,000,000 / (256 - D3h) = 22,222.22 samples/second.
A 512-sample block therefore requests about 43.40 refill interrupts per second,
or one every 23.04 ms. These are code-derived intended rates; the failed
runtime capture did not audition or measure the audio output.
The sample-generation loop at 1235h is especially revealing. It mixes four
byte streams spaced 0200h apart into a DMA output buffer. The fast path simply
adds low and high bytes separately and divides by four:
1265 mov ax,[si+0200h]
1269 mov cl,al
126B add dx,cx ; low-byte accumulator
126D mov cl,ah
126F add bx,cx ; high-byte accumulator
1271 mov ax,[si+0400h]
1275 add dx,low(ax)
1279 add bx,high(ax)
127D mov ax,[si+0600h]
1281 add dx,low(ax)
1285 add bx,high(ax)
1289 lodsw ; stream 0, advance SI
128C add dx,low(ax)
1290 add bx,high(ax)
1292 shr dx,2
1295 shr bx,2
1298 mov al,dl
129A mov ah,bl
129C stosw ; two output samples
129D xor dx,dx
129F xor bx,bx
12A1 dec bp
12A2 jne 1265h
The alternate path, selected by byte DS:6400h == FFh, clamps accumulators to
0000h..03FCh and carries fractional error forward:
12D3 cmp dx,03FCh
12D7 jg clamp_dx_high
12D9 or dx,dx
12DB js clamp_dx_low
12DD cmp bx,03FCh
12E1 jg clamp_bx_high
12E3 or bx,bx
12E5 js clamp_bx_low
12E7 xor ax,ax
12E9 ror dx,2
12EC adc al,dl
12EE ror bx,2
12F1 adc ah,bl
12F3 stosw
12F4 rol dx,2
12F7 rol bx,2
12FA mov cl,al
12FC shl cx,2
12FF sub dx,cx ; keep low-channel remainder
1303 mov cl,ah
1305 shl cx,2
1308 sub bx,cx ; keep high-channel remainder
For the full 0200h block, CX >> 1 gives 256 loop iterations. Both mixer
paths read four words per iteration: 2,048 source bytes across the four lanes,
then write one word, for 512 output bytes. The fast path performs eight
byte-to-word accumulations and two right shifts per iteration. The alternate
path keeps the same memory traffic while adding four bounds tests, possible
clamps, and residual-error carry between output pairs.
After filling a buffer, the code computes its physical DMA address from
DS * 16 + buffer_offset, writes the page/base/count values into CS:0000,
CS:0002, and CS:0004, waits for vertical retrace, calls the small animation
routine, and waits until the IRQ handler flips CS:0007:
1327 mov ax,[bx+6406h] ; buffer offset
132B mov bx,ds
132F shl bx,1
1331 rcl dx,1
... ; DS * 16
133F add bx,ax
1344 mov dh,49h ; DMA page high component
134C mov cs:[0000h],ax
1350 mov cs:[0002h],bx
1355 mov cs:[0004h],cx
13E2 call 0D19h ; visual tick while waiting
13E7 mov dx,03DAh
13EA in al,dx
13EB and al,08h
13ED jz 13EAh ; retrace wait
13F7 cmp byte cs:[0007h],0FFh
13FD jne 13E2h
1405 advance buffer page
This is a proper audio-first design. The visual tick is subordinate to buffer turnover; the largest hot path is not a 3D renderer or a copper-bar routine, but a sample mixer/downsampler feeding Sound Blaster DMA.
The teardown at 2429h..2452h is also explicit. It restores the previous
sound IRQ vector through DOS (11E7h), sends DSP D3h (pause 8-bit DMA) and
then D0h (continue 8-bit DMA), restores the low exception vectors saved by
the probe through 11FEh, resets the DSP, and frees player allocations. It
does not restore the pre-player master-PIC mask after 11ADh unmasked the
selected IRQ. Thus a successful long run can return with that IRQ line still
unmasked even though its old interrupt vector has been restored—a small but
real cleanup leak hidden by the short failure-path capture.
What Each Resource Probably Does
Based on tags, loading order, runtime, and code paths:
MAING main graphics block; contains or expands to the 64000-byte title screen
ANIMA animation/pointer-list material used by the small A000 RLE and point plotter
MOD1 large sound/module payload and player state; around 120 KB by the intro text
M terminal or module-table marker in the inline resource ID string
The resource loader supports more than this one title picture, but the runtime
capture only proves the MAING title stage plus the failure text. The static
player code proves that the longer intended path is Sound Blaster-based.
Why The Runtime Is Short In DOSBox-X
The short capture should not be mistaken for absence of code. The sequence is:
1. open self EXE
2. load MAING
3. set mode 13h
4. upload/fade palette
5. copy title picture to A000
6. load ANIMA and MOD1
7. call the module/Sound Blaster initializer
8. initializer reports failure
9. restore text mode and print the built-in SB warning
The static code has a normal DSP reset path, base-port probe, IRQ-selection stubs, DMA programming, vector hook/restore, and an actual mixer. The failure is therefore most likely at the compatibility boundary between this 1991 probe / IRQ expectation and this DOSBox-X capture environment, not because the archive lacks the sound code.
Summary
Friday the 13th is a small visible intro wrapped around a larger
Sound Blaster payload. The VGA side is direct and economical: mode 13h, one
screen-sized copy, palette fade through 03C8h/03C9h, and small point/RLE
helpers. The loader side is more ambitious than the short runtime suggests:
self-opened overlay records, segment allocation, CRC-checked compressed chunks,
and a decode loop with tables and sliding-window copies. The sound side is the
real center of gravity, with four-stream sample mixing and 8-bit DMA refill
machinery. In the tested emulator setup the intro exits before the long audio
section, but the recovered inner loops show the intended design clearly.