Analysis model: gpt-5.5 xhigh
Funny by CSG Productions - Technical Dissection
Funny is a November 1992 MS-DOS demo by CSG Productions. Demozoo's CSG
Productions group page lists Funny as an MS-DOS demo from November 1992, and
Pouet's CSG Productions group page lists the same production with the same
month. The Hornet 1992 index carries it as funny.zip, Funny by CSG.
Release year: 1992
This is another CSG packed-MZ demo in the same broad family as Falling and
Evil, but it is not just a clone of either. The recovered program draws a
space/Foundation screen from planar image segments, probes for a Sound Blaster,
contains both CT-VOICE-style Sound Blaster support and STMIK 0.2 Scream
Tracker interface code, installs PIT and keyboard interrupt hooks, and uses a
compact four-plane transparent blitter whose marker is FEh.
There is no public runtime screenshot in the sources I found. The first image below is a static reconstruction from the recovered asset segments and palette table, not a DOSBox capture. The second image is a generated technical map of the loader and inner loops.
Sources
- Demozoo CSG Productions group page: https://demozoo.org/groups/82301/
- Pouet CSG Productions group page: https://www.pouet.net/groups.php?which=1435
- Hornet 1992 index: https://files.scene.org/get/mirrors/hornet/demos/1992/00_index.txt
- Hornet archive download used for this local analysis: https://files.scene.org/get/mirrors/hornet/demos/1992/funny.zip
Visual Reference


The reconstructed still is built from the code path that calls the recovered
13ED planar blitter with source segments 2895h, 1D55h, 35F1h,
5100h, and then a bottom strip from 10ACh. It should be treated as a
static reconstruction of the initial composition, not as proof of exact runtime
timing, CRTC start offset, or later animation state.
Archive And File Shape
Local hashes:
9ab38bf1650b4fc6f02702a7d66d4228c7ba7e066391d4443c3d0e76d9c1513d funny.zip
85a86a00b98e6ad3f0891b268d49a01bca84f5a987f1fec5a20d251707efcba0 funny.exe
bb2f358b3a4757971c2f0895293ede15ad35624bd71659059cd4e959f0434257 recovered current-CS image
0503bf12d9359cf63f914c3d97118e46273e299243d120e13808c83d1de6d542 4 MiB emulator memory dump at restore stop
0ee979fd6a2c6e7540410d92db239d0c78cbd7d1f87c87b49236b9abd98dd46c funny-csg-reconstructed-frame.png
8d5199ef148037bd5f0df7601c3592c18331c44162ff82539e10fd45fd6580cf funny-csg-runtime-map.png
The archive contains one file:
funny.exe 107,556 bytes 1992-11-28 14:56
The executable header contains the plain label:
Funny.Exe 28-11-92 CSG Productions!
The restored strings include the runtime user-facing messages:
Shit, sorry lamer, this is a VGA demo!
Yo, Sound Blaster was not detected!
Yo, Sound Blaster detected! Use? (y):
Whats your IRQ setting (2,3,5,7) [7] ?
Warning: This loader requires 340k and no memory managers installed.
The recovered memory also contains:
CT-VOICE
Creative Sound Blaster Card
<STMIK020>
Scream Tracker Music Interface Kit V0.2
Creative Voice File
So the sound path is mixed: CT-VOICE / Creative Voice support is present, and the STMIK 0.2 player/interface is present too.
MZ Carrier
The packed funny.exe MZ header:
physical file size 107,556 bytes
MZ header size 512 bytes
relocation entries 0
CS:IP at entry 1A0A:000E
SS:SP 5190:0080
minalloc 3776h
maxalloc FFFFh
entry file offset 1A2AEh
The zero relocation count and entry point near the end of the file match the CSG packed-carrier pattern. The actual entry segment begins with control words and a small mover:
[000A] = 376Dh
[000C] = 0184h
Entry instructions:
push ax
push es
push cs
pop ds
mov cx,[000ch]
mov si,cx
dec si
mov di,si
mov bx,cs
add bx,[000ah]
mov es,bx
std
rep movsb
push bx
mov ax,002ch
push ax
retf
So the entry copies 0184h bytes from the entry segment to CS+376Dh, moving
backward so overlap is safe, then far-returns to the copied code at
(CS+376Dh):002Ch.
The copied depacker then runs in high memory. In the Unicorn trace it was
executing at segment 6177h before the restored runtime appeared.
Restore Boundary
I emulated the MZ load with image segment 1000h and PSP segment 0FF0h,
then stopped at the first real BIOS call after unpacking:
step count 1,779,249
INT 10h
CS:IP 12DC:1164
AX 1A00h
BX 0000h
CX 0004h
DX 158Ch
DS 12DCh
ES 0FF0h
SS:SP 1000:0100
The recovered current-CS image is COM-like. It begins:
e9 58 11 00 a0 00 10 ...
Disassembled:
0000: jmp 115bh
0003: dw 0a000h ; A000h segment value used by draw code
The aligned runtime entry at 115Bh is clean:
115b: mov ax,cs
115d: mov ds,ax
115f: mov ax,1a00h
1162: int 10h
1164: cmp bl,08h
1167: je 1175h
1169: mov dx,1067h
116c: mov ah,09h
116e: int 21h
1170: mov ax,4c00h
1173: int 21h
That is the VGA gate. BL=08h is the accepted VGA colour-display return from
INT 10h AX=1A00h. If it fails, the demo prints its VGA error message and
returns to DOS.
Sound Blaster Probe And Prompt
After the VGA gate, the code probes Sound Blaster DSP bases:
1381: mov bx,0210h
probe_base:
mov al,01h
mov dx,bx
add dx,0006h
out dx,al ; DSP reset high
call wait_retrace
xor al,al
out dx,al ; DSP reset low
call wait_retrace
mov dx,bx
add dx,000ah
in al,dx ; DSP read/status area
cmp al,0aah
je found
add bx,0010h
cmp bx,0270h
jl probe_base
xor bx,bx ; no card found
found:
ret
The caller stores the found base in CS:[0014]. If no card is detected, it
prints the no-Sound-Blaster message and runs visual-only. If a card is found,
it asks whether to use it. Answering N or n forces CS:[0014] = 0.
If sound stays enabled, the IRQ prompt maps ASCII input to a small IRQ word:
'1' -> 0Ah
'2' -> 02h
'3' -> 03h
'5' -> 05h
'7' -> 07h
The 1 -> 0Ah case is the usual PC convention for IRQ 2 cascaded to IRQ 9.
Main Runtime Order
After the prompt, the high-level order is:
1175 probe Sound Blaster base
11FE install keyboard vector / setup helpers
1204 set up VGA mode and clear screen
1207 initialize scroll/CRTC state
120A draw the main Foundation assets through 13ED
1218 draw an additional bottom strip through 13ED
122C copy logo/text strips with 28B0
1237 initialize CT-VOICE/STMIK if sound enabled
1267 palette fade in
128A palette/asset transition
1290 copy/update a lower strip
12E9 frame loop: mask IRQ, wait retrace, scroll/update, music tick
1305 keyboard poll
132C shutdown path
1345 return to text mode
The code polls BIOS keyboard in the frame loop:
mov ah,01h
int 16h
je frame_loop
mov ah,00h
int 16h
cmp ah,01h ; Esc
je exit
If the key is not Esc, it toggles CS:[0005]. That byte changes a scroll
speed path in the 1892 update routine, so Space or another accepted key
acts like a mode/speed toggle.
VGA Setup
The mode setup at 1A80:
mov ax,0013h
int 10h
cli
xor al,al
mov dx,03c8h
out dx,al
inc dx
mov cx,0300h
xor al,al
out dx,al repeated 0300h times
call wait_retrace
mov dx,03c4h
mov ax,0604h
out dx,ax
Then it touches the attribute controller and CRTC:
in al,03dah
mov dx,03c0h
out 10h,61h
out 11h,00h
out 20h
mov dx,03d4h
unlock CRTC index 11h
write 19h CRTC registers from table at 1A67h
Finally it selects all planes and clears A000h:
mov dx,03c4h
mov ax,0f02h
out dx,ax
mov es,cs:[0003h] ; A000h
xor di,di
mov cx,8000h
xor ax,ax
rep stosw
sti
ret
The vertical retrace wait at 1AFD is the classic two-phase 03DAh loop:
push ax
push dx
mov dx,03dah
wait_until_not_in_retrace:
in al,dx
test al,08h
jnz wait_until_not_in_retrace
wait_until_in_retrace:
in al,dx
test al,08h
jz wait_until_in_retrace
pop dx
pop ax
ret
The 13ED Planar Blitter
The central recovered graphics loop is 13ED. It is a four-plane transparent
copy into A000h. It is close in spirit to the CSG/Fairlight planar blitters
seen in other 1992 programs, but the transparency marker is different:
Funny skips bytes greater than or equal to FEh.
The caller passes:
DS:0000 source image segment
DI destination offset in the A000h plane space
CX number of rows
13AC draws four large blocks:
lcall 12dc:2ab0 ; AX = 2895h
mov ds,ax
mov di,0000h
mov cx,00abh
call 13ed
lcall 12dc:2aa0 ; AX = 1D55h
mov ds,ax
mov di,0050h
mov cx,0090h
call 13ed
lcall 12dc:2ac0 ; AX = 35F1h
mov ds,ax
mov di,00A0h
mov cx,008Ah
call 13ed
lcall 12dc:2ae0 ; AX = 5100h
mov ds,ax
mov di,00F0h
mov cx,0093h
call 13ed
Later, the main path draws a bottom strip:
mov ax,10ach
mov ds,ax
mov di,0d5c4h
mov cx,001ch
call 13ed
The blitter itself:
13ed: mov es,cs:[0003h] ; A000h
13f2: xor si,si
row_loop:
push cx
push si
push di
; plane 0
push di
push si
mov dx,03c4h
mov ax,0102h
out dx,ax
mov cx,0050h
plane0:
lodsb
cmp al,0feh
jb write0
inc di
jmp after0
write0:
stosb
after0:
add si,0003h
loop plane0
pop si
pop di
inc si
; same body for masks 0202h, 0402h, 0802h
The four plane passes are identical except for the map mask and initial source phase:
plane 0: mask 0102h, source phase +0
plane 1: mask 0202h, source phase +1
plane 2: mask 0402h, source phase +2
plane 3: mask 0802h, source phase +3
After all four passes:
pop di
pop si
pop cx
add si,0140h
add di,0140h
loop row_loop
ret
Pseudocode:
for each output row:
for plane, mask in [(0,0102h), (1,0202h), (2,0402h), (3,0802h)]:
out 03C4h, mask
si = row_source + plane
di = row_dest
repeat 50h times:
al = source[si]
if al >= FEh:
di += 1
else:
A000_plane[di] = al
di += 1
si += 4
row_source += 0140h
row_dest += 0140h
The width is 50h bytes per plane, so four phases cover 50h * 4 = 320
pixels. The 0140h row step is also 320. This is why the reconstructed asset
composition can map cleanly into a 320x200 frame: the source is already laid
out in four interleaved VGA phases, and the CPU only has to test one marker
byte and store one byte per visible pixel.
The static reconstruction image was made by replaying these five known calls
against the recovered memory dump and palette table at 031Ch.
Scroller / CRTC Update
The update routine at 1892 maintains a horizontal or start-address phase in
CS:[0006] and a fractional accumulator at 1890h:
mov es,cs:[0003h] ; A000h
mov ax,cs:[0006h]
mov cs:[000ch],ax
add ax,0003h
if cs:[0005] != 0:
inc word cs:[1890h]
inc ax
add word cs:[1890h],3
if ax >= 0280h:
ax -= 0280h
mov cs:[0006h],ax
If the fractional accumulator reaches at least 4, it copies a narrow vertical
strip into the screen; otherwise it jumps to the CRTC start-address update.
The strip copy selects all planes, computes a destination from D750h plus
CS:[0006] >> 2, and copies 28 rows:
mov dx,03ceh
mov ax,4105h
out dx,ax
mov dx,03c4h
mov ax,0f02h
out dx,ax
di = D750h + (phase >> 2)
si = selected source column
for row in 0..1Bh:
al = ES:[SI]
ES:[DI] = al
ES:[DI-00A0h] = al ; in one branch
si += 0140h
di += 0140h
The source column is selected through a byte script at 15EEh and word table
at 1480h. That makes the scroller/update path data-driven rather than a
single fixed strip.
At 1A21, the visible start address is written to CRTC indexes 0Ch and
0Dh:
mov bx,0d700h
mov ax,cs:[0006h]
shr ax,1
shr ax,1
add bx,ax
mov dx,03d4h
mov al,0ch
mov ah,bh
out dx,ax
mov al,0dh
mov ah,bl
out dx,ax
ret
So Funny is not redrawing the whole screen each frame. It scrolls or shifts
by combining CRTC start-address movement with narrow strip refreshes.
Palette Fades
There are several full-palette fade routines. They all start from the palette
table at 031Ch, set DAC index 0 through 03C8h, and write 768 component
bytes through 03C9h, with retrace waits between each 256-byte block.
Fade-in at 1B0F clamps components upward:
threshold = CS:[1B1Ah]
for 768 component bytes:
al = *palette++
if threshold > al:
al = threshold
out 03C9h, al
threshold += 1
repeat until threshold > 3Fh
Fade-up at 2905 is similar but stops at 40h. Fade-out at 296F counts the
threshold down to zero:
threshold = 3Fh
while threshold != 0:
for 768 component bytes:
al = *palette++
if threshold < al:
al = threshold
out 03C9h, al
threshold -= 1
wait retrace
The important detail is that this is not a high-level BIOS palette fade. It is direct DAC output with per-component clamps, deliberately paced by retrace.
PIT And Keyboard Interrupts
The timer installer at 1B9B saves the old INT 08 vector, installs a local
handler at 1B81, waits for retrace, programs PIT channel 0, measures the
counter, and computes reload bytes:
cli
es = 0000h
save es:[0020h], es:[0022h]
es:[0020h] = 1B81h
es:[0022h] = CS
sti
call wait_retrace
out 43h,36h
out 40h,00h
out 40h,00h
call wait_retrace
latch/read PIT channel 0
neg ax
shr ax,1
store calibrated count at 1B79h
compute reload at 1B7Bh
out 43h,36h
out 40h,low
out 40h,high
The local INT 08 body starts:
push ax
mov al,20h
out 20h,al ; EOI
call wait_retrace
mov al,36h
out 43h,al
...
iret
The keyboard hook at 26EA reads port 60h:
in al,60h
cmp al,01h ; Esc
je pass_to_old
cmp al,39h ; Space
je pass_to_old
in al,61h
or al,80h
out 61h,al
restore old value to 61h
out 20h,20h
iret
pass_to_old:
ljmp old_int09
So most keystrokes are swallowed, while Esc and Space are allowed through to the old handler. The BIOS keyboard polling loop then observes Esc for exit and uses non-Esc key activity to toggle the internal mode byte.
CT-VOICE Dispatcher
The far-call target 1010:0000 begins with a CT-VOICE header and Creative
Sound Blaster strings. Its callable entry at 1010:0754 is a dispatcher:
pushf
push ds es ax bx cx dx di si bp
mov bp,sp
mov ax,cs
mov ds,ax
mov es,ax
cld
cmp bx,000eh
jae bad_function
cmp bx,0004h
jb dispatch
cmp byte [00b1h],00h
je bad_function
dispatch:
shl bx,1
call word [bx+0085h]
mov [bp+0Ch],ax
...
retf
bad_function:
mov word [bp+0Ch],0FFFFh
retf
The CSG wrapper routines at 29D9..2A8C select dispatcher function numbers by
putting small values in BX and far-calling 1010:0000:
29EF -> BX=0
29E4 -> BX=1
29D9 -> BX=2
29FA -> BX=3
2A05 -> BX=4 with AX=1
2A15 -> BX=4 with AX=0
2A25 -> BX=5
2A3B -> BX=6
...
2A88 -> BX=0Dh
The main path uses these wrappers to set IRQ/base, initialize, start, poll,
and stop sound. It also calls 1010 through CT-VOICE for Creative Voice data
segments found at 5C7Ch and 60EBh.
STMIK 0.2 Path
The far segment 158Ch begins:
<STMIK020>
Scream Tracker Music Interface Kit V0.2
Copyright (C) 1991 Sami Tammilehto.
It has its own far-call wrapper interface. The first part stores an internal
function pointer at CS:[000A]/[000C], and the callable wrappers load AX
with function IDs 0..6 before calling the common routine at 000Fh.
At 158C:011F, the player path stores incoming registers into internal state:
mov cs:[6823h],dx
mov cs:[6810h],cx
and cx,000fh
mov cs:[6812h],cx
...
jmp 50B0h
The demo's own code calls 158C:000F directly with:
AX = 0, BX = IRQ/base-shaped value, CX = SB base, DX = 3E80h
AX = 5
AX = 3, BX = 1
AX = 1 with segment from 2AD0h
AX = 4 during frame loop
AX = 2 on exit
That matches a tracker-interface lifecycle: configure, initialize, start, tick or poll, and stop.
Bottom Bar / Sample Table Renderer
The routine at 20DC only runs when sound is enabled:
cmp word cs:[0014h],0
jne continue
ret
It selects VGA planes 0..2:
mov dx,03c4h
mov ax,0702h
out dx,ax
Then it reads 60 bytes from the sound/sample pointer stored at CS:[0010] /
CS:[0012], stores the original values into a circular table at 1C9Ch,
subtracts 2 from the live source byte with floor at 0, and advances the source:
for i in 0..59:
al = DS:[SI]
table[(BX+i) & 03FFh] = al
al = max(al - 2, 0)
DS:[SI] = al
SI += 1
Then it draws 40 columns of vertical paired pixels near the bottom:
cx = 28h
di = D5DEh
si = ring_index + 14h
bp = 14h
for column in 0..27h:
bh = cs:[bp + 209Ch] ; previous height
bl = cs:[si + 1C9Ch] ; new height
if bh != 0:
cs:[bp + 209Ch] = bl
bl >>= 2
bh >>= 2
draw bl coloured pairs upward from DI using colour 8Ch.. increasing
clear the remaining old height with colour 00h
si += 1
bp += 1
di += 2
This is a classic sound-meter decay loop. The source values decay by 2 each frame, and the renderer updates only the visible bar columns needed near the bottom area.
Static Reconstruction Method
The reconstructed frame in this article was built by replaying these 13ED
calls from the recovered memory dump:
source 2895h, destination 0000h, rows 00ABh
source 1D55h, destination 0050h, rows 0090h
source 35F1h, destination 00A0h, rows 008Ah
source 5100h, destination 00F0h, rows 0093h
source 10ACh, destination D5C4h, rows 001Ch
For display, each plane byte was mapped as:
x = plane + 4 * (DI mod 320)
y = DI / 320
That matches the 50h bytes per plane and 0140h row stride. Palette bytes
were taken from CS:031Ch and scaled from VGA 0..63 to 0..252 RGB.
The reconstruction is good for understanding the asset layout and initial composition. It is not a timestamp, and it does not prove the exact CRTC start address or animation phase seen by a real monitor at any moment.
Conclusion
Funny is a compact but substantial 1992 PC demo. Its visible Foundation
screen is built from preformatted planar assets; its smoothness comes from a
combination of CRTC start-address movement, narrow strip refreshes, retrace
waits, and palette fades; and its audio layer is split between CT-VOICE-style
Sound Blaster support and STMIK 0.2 tracker support.
The most important inner loop is the 13ED blitter. It explains the whole
visual data format: four interleaved source phases, one VGA map mask per
phase, FEh/FFh as transparent sentinels, 50h bytes per plane, and 140h
bytes per row. That is exactly the kind of practical, hardware-shaped 1992 PC
code that makes these early demos more interesting than their short runtime
sequences suggest.