MODEL MEDIUM,BASIC
.STACK 20H
.386
.CODE

;SUB RELXCOMPRESS(BYVAL DESTSEG,BYVAL DESTOFF,BYVAL SRCSEG,BYVAL SRCOFF,BYVAL PERCENT)
;STACK
;DEST SEG       =16
;DESTOFF        =14
;SOURCE SEG     =12
;SOURCE OFF     =10
;PERCENT        =8
;QB RETURN SEG  =6
;QB RETURN OFF  =4
;DS             =2
;BP             =0
;DS:SI		=SRC SEG:SRC OFF
;ES:DI		=DEST SEG:DEST OFF

PUBLIC RELXCOMPRESS
RELXCOMPRESS PROC
PUSH DS
PUSH BP
MOV BP,SP        ;POINT STACK POINTER TO BP
MOV ES,[BP+16]   ;POINT ADDRESS OF DEST TO ES
MOV DI,[BP+14]   ;POINT CORRECT OFFSET FO DEST
MOV DS,[BP+12]   ;POINT ADDRESS OF SRC TO DS
MOV SI,[BP+10]   ;SRC OFFSET
;REGS SUMMARY
;ALL FREE
MOV AX,200       ;NORMAL NO COMPRESSION
MOV DL,[BP+8]    ;PERCENT 0 TO 100
SHL DL,1         ;MUL BY TWO TO GET CORRECT ASPECT   100=200,50=100,ETC
MOV DH,DL        ;SAVE PERCENT TO DH

DIV DL           ;DIV AX BY DL
                 ;AL=QUOTIENT
MOV AH,AL
MOV DL,DH

LBL_PLOT_LINE:
        MOV CX,80       ;INIT COUNTER(DOUBLE WORD) 320/4
        REP MOVSD       ;COPY IT
        DEC AL
JZ LBL_SKIP_JUMP
        ADD SI,320      ;ADD ONE LINE TO SRC
JMP LBL_NEXT_LINE
LBL_SKIP_JUMP:
        MOV AL,AH
LBL_NEXT_LINE:
        DEC DL          ;DEC HEIGHT COUNTER
JNZ LBL_PLOT_LINE

POP BP
POP DS
RET 10

RELXCOMPRESS ENDP

END

