TETRIS.COM
Introduction
TETRIS.COM1 is a game written using 80386 assembler in the so-calledVGA mode 13h2 for MS-DOS™.
Without much code golfing the result is a compressed3 executable of 1663 bytes. This is less than the size of the screenshot (68%, 2429 bytes optimized PNG)!

Features
- single player
- two player over IPX
- a font created by using the standard BIOS font, modify it with code which results in a (ugly) stencil-like look
Source code
Probably on a 1.44″ floppy somewhere, but here are some disassembled snippets. Back by popular demand.
The source code is 23 kB and approximately 1200 lines, including the graphics. It is written in Borland’s Turbo Assembler syntax.
The build script
The build script assembles the source using as many passes as needed (-m), then links using
the TINY memory model. To pack the file from ~8 kB to the mentioned 1663 bytes a
so-called executable packer3 is used.
tasm tetris.asm -mtlink tetris -tapack tetris.com tetris.com
Initialization
.model tiny.code.386include blocks.incinclude font.inc; jumpsorg 100hstart: mov ax,1a00hint 10hcmp al,1ahjne novgacmp bl,7jb novgajmp oknovga: mov dx,offset errmsgmov ah,9int 21hreterrmsg db 'No VGA detected',13,10,'$'ok: xor bx,bx ;set keyboard rate&delay fast!mov ax,305hint 16hcall initcall drawbucket...
Drawing a tetromino
putblock proccall calcposmov dx,4copybrick:mov bp,diadd di,word ptr [offset data_147+bx]mov cx,8copyrow:movsw ; copy 8 bytesmovswmovswmovswadd di,320-8loop copyrowmov di,bpadd bx,2dec dxjnz copybrickretputblock endp
Calculate position of a tetromino
calcpos procmov ax,0a000hmov es,axmov cl,5shl si,clmov cl,3shl di,clmov dx,siadd dx,dimov cl,5shl si,cladd si,offset data_22mov cl,5shl di,cladd si,dishl bx,1shl bp,1mov di,[bx+data_17]add di,[bp+data_18]mov bx,dxretcalcpos endp
Clear full lines
clrlines proc ;ds=source, es=destxor di,dixor si,sixor bp,bp ;linectloc_23: mov bx,72 ;9*8loc_24: cmp byte ptr es:[bx+di],0 ; full?je loc_27sub bx,8jnc loc_24inc bp ;linect++mov ax,dimov bx,siloc_25: mov dx,8loc_26: mov cx,40 ; 10 columns * 8 bytes (= 40 words)rep movswadd di,320-80add si,320-80dec dxjnz loc_26sub di,16*320sub si,16*320cmp si,0f600hjne loc_25mov si,bxmov di,axloc_27: add si,8*320add di,8*320cmp si,23*8*320jne loc_23retclrlines endp
Downloads
| Filename | Note | Type | Size |
|---|---|---|---|
| tetris.com | Missing IPX | COM | 1663 bytes |
| tetris.png | - | PNG | 2429 bytes |