home *** CD-ROM | disk | FTP | other *** search
- ; pcbunrun.asm
- ;
- ; 5/5/88 by Ted
- ;
- ; Splash-style image unrunner for OWL
- ; THIS FILE IS FOR LARGE-DATA MODELS ONLY
- ;
- ; Copyright (c) 1988, 1989 Oakland Group Inc.
- ; ALL RIGHTS RESERVED
- ;
- ;------------------------REVISION HISTORY--------------------------------------;
- ;------------------------------------------------------------------------------;
- include PCDECL.MAC
-
- PSEG
- ; ---------------------------------------------------------------------------- ;
- ; int bunrun(dest_addr, nbytes, runcode)
- ;
- ; Unrun in place into max nbytes bytes at addr
- ; firstrun and runsize describe the runned data
- ; dest_addr is a doubleword in form seg, offset
- ; - runcode is runsize and firstrun as lo and hi of long value
- ; - returns outsize, -1 if overflow
-
- pubproc DIGPRIV bunrun <daddr, dptr, nbytes, runsize, firstrun>
- push bp
- mov bp, sp
- pushm <ds, es, si, di>
-
- lds si, [bp].daddr ; reg. ds = saddr seg
- les di, [bp].daddr ; reg. es = daddr seg
- mov bx, [bp].firstrun
-
- ; move runned stuff from soff to runstart = soff+nbytes - runsize
- add di, [bp].nbytes
- mov dx, di ; dx = end of runbuf and outbuf
- mov cx, [bp].runsize
- sub di, cx
- mov [bp].firstrun, di ; firstrun is now runstart address
-
- push bx ; save bx for later
- push dx ; save dx for later
-
- ; di > si : negative move
- add si, cx ; point si and di to end of area
- dec si
- add di, cx
- dec di
-
- std
- shr cx, 1
- jnc ndow
- movsb
- jcxz ndone
- ndow:
- dec si
- dec di
- rep movsw
- ndone:
- cld
-
- pop dx ; restore end address of runbuf and outbuf
- pop bx ; restore address of first run
-
- ; set up si and di to start
- mov si, [bp].firstrun
- les di, [bp].daddr ; reg. es = daddr seg
-
- NEWMOV:
- cmp si, dx ; see if we are done
- jz done
- cmp di, dx ; see if we have overflowed
- jae overflow
-
- ; find count of bytes until next run and blast them out
- mov cx, bx
- cmp cx, -1
- jne nosubs
- mov cx, [bp].runsize ; substitute buf end for next-run start
- nosubs:
- add cx, [bp].firstrun ; cx = nextrun - curpos
- sub cx, si
- jcxz NEWRUN
-
- ; test for error of run too big
- mov ax, dx
- sub ax, di
- cmp cx, ax
- jbe okmov
- mov cx, ax
- jcxz overflow
- okmov:
- rep movsb ; blast out bytes until next run
-
- NEWRUN:
- mov ax, dx
- sub ax, si
- jz done ; test for all done
- cmp ax, 2 ; test for error of incomplete run code
- jb abort ; allow no next-run ptr because it's redundant
- ; load up run data
- mov bx, ds:[si+2] ; get next run ptr
- mov cl, ds:[si+1] ; get run count
- mov ch, 0
-
- ; test for error of run too big
- mov ax, dx
- sub ax, di
- cmp cx, ax
- jbe okrun
- mov cx, ax
- jcxz overflow
- okrun:
- mov al, ds:[si] ; get run byte
- add si, 4
-
- rep stosb ; blast out the run
- jmp NEWMOV
-
- overflow:
- mov ax, -1
- jmp short fini
- done:
- abort:
- mov ax, di
- les di, [bp].daddr ; reg. es = daddr seg
- sub ax, di
- fini:
- popm <di, si, es, ds>
- pop bp
- ret
- endproc bunrun
- ; ---------------------------------------------------------------------------- ;
- ENDPS
- end
- ; ---------------------------------------------------------------------------- ;
-