BBS: Inland Empire Archive Date: 12-28-92 (06:44) Number: 362 From: RICH GELDREICH Refer#: NONE To: ALL Recvd: NO Subj: Bload Compressor/6 Conf: (2) Quik_Bas
'Page 1 of DECOM13.ASM begins here. ;TASM v2.0 source code for DECOM13.OBJ. By Rich Geldreich, 1992 ;A LZ77 style sliding dictionary decompressor for SCREEN 13 images. .286 ;<-sorry 8088 & 8086 guys, IDEAL ;it's 1992 get a real CPU! MODEL SMALL CODESEG PUBLIC Decom13 PROC Decom13 INPTR EQU [dword ss:bp+6] P = 2 Cld ;clear direction flag Push bp ;setup stack frame Mov bp, sp Push ds es si di ;preserve important regs Lds si, INPTR ;get pointer from stack Cmp [word ds:si], 'R'+'G'*256 ;is an image there? Je @@OK ;nope Jmp @@Exit @@OK: Inc si ;get by signature Inc si Mov [word cs:ISeg1+1], ds ;a little self modifying code Mov [word cs:ISeg2+1], ds ; can't hurt(I think). Jmp @@10 ;empty the prefetch @@20: Mov dx, 03C4h ;sequencer register Mov al, 1 ;clocking mode register Out dx, al Inc dx In al, dx Or al, 32 ;set screen off bit Out dx, al ;go for screen disable Mov dl, 0DAh ;wait for vertical retrace @@30: In al, dx And al, 8 Jz @@30 Mov dl, 0C8h ;dx=03C8h Mov cx, 768 ;prepare to set the palette Xor al, al ;start at attribute 0 Out dx, al Inc dx Rep Outsb ;output the palette Push 0A000h ;es=screen's segment Pop es Xor di, di ;di=output offset Mov dx, di ;dx=# bits left in bitbuffer EVEN ;-decode loop starts here- @@MoreBits: Lodsw ;prime the bitbuffer Mov dl, 16 ;16 more bits now Mov bp, ax Shr bp, 1 ;character or match? Jc @@Match ;go for match if carry set EVEN @@NoMatch: Movsb ;store one character @@MainLoop: Dec dx ;any more bits left? Jz @@MoreBits ;get more if not Shr bp, 1 ;character of match? Jnc @@NoMatch ;go if character(carry=0) @@Match: ;-handles a string match- Lodsw ;get match length and Mov cx, ax ; and distance Shr ax, 4 ;shift by the match length Neg ax ;got -distance now Add ax, di ;ax=match position And cx, 0Fh ;get low 4 bytes for length Add cl, 3 ;add in length threshold Cmp cl, 18 ;is this a big match? Je @@GetMore ;go get 1 more byte if so Xchg ax, si ;save si and set si to match Mov bx, es ; position Mov ds, bx ;ds=es=0A000h Rep Movsb ;copy the string Mov si, ax ;restore ds and si ISeg1: Mov ax, 09999h ;<--self modifying code Mov ds, ax Jmp @@MainLoop ;go again EVEN @@GetMore: Mov bx, ax ;save match pos in bx Xor ax, ax ;get one more byte for Lodsb ; match length Add cx, ax Cmp cx, 273 ;end of image code? Je @@Exit ;if so then done Xchg bx, si ;save si and set si to match 'Continued on page 2 --- MsgToss 2.0b * Origin: Computer Co-Op - Voorhees, NJ | Ted Hare (1:266/29)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET