include doszip/doszip.inc
include	conio.inc
include	mouse.inc
include string.inc
include dos.inc
ifdef __ROT__
include tinfo.inc
endif

	public	prect_show	; DS:AX
	public	prect_hide
	public	prect_close
	public	prect_open
	public	prect_open_ab
	public	prect_clear

	public	fbputsl		; fblk:DWORD, x:WORD, y:WORD
	public	fbputsd		; fblk:DWORD, x:WORD, y:WORD
  ifdef __LFN__
	public	fbputll		; fblk:DWORD, x:WORD, y:WORD
	public	fbputld		; fblk:DWORD, x:WORD, y:WORD
  endif
	public	fbputlw		; fblk:DWORD, x:WORD, y:WORD
	public	fbputdate	; fblk:DWORD, x:WORD, y:WORD
	public	fbputtime	; fblk:DWORD, x:WORD, y:WORD
	public	fbputfile	; fblk:DWORD, x:WORD, y:WORD

OFF_INFO	equ	0
OFF_FRAME	equ	2
OFF_PROC	equ	4
OFF_RECT	equ	6

_DATA	SEGMENT

cp_strmega	db	0,'KMGT'
format_7luc	db	'%7lu%c',0
format_10lu	db	'%10lu',0
format_02lX	db	' VOL-%02lu ',0

cp_subdir	db	" SUBDIR ",0
cp_updir	db	" UP-DIR ",0

PRECTTITLE_VSL	db	10,9,'Name',9,'    Name',9,' '
cp_name		db	'Name',0
PRECTTITLE_VSD	db	10,9,'Name   ³   Size   ³  Date  ³ Time',0
ifdef __LFN__
PRECTTITLE_VLL	db	10,9,'Name',9,9,'  Name',0
PRECTTITLE_VLD	db	10,9,'   Name',9,9,' Size',9,'³  Date',0
endif
PRECTTITLE_VWL	db	10,9,9,'    Name',0

; Frame set

PRECTFRAME_VSL	db	14,13	; Length, X-Pos
PRECTFRAME_VWL	db	0	; terminate
PRECTFRAME_VSD	db	14,0,10,24,0
PRECTFRAME_HSL	db	14,13,14,39,14,52,0
PRECTFRAME_HSD	db	12,13,7,33,12,52,8,72,0
ifdef __LFN__	; using long file names
PRECTFRAME_VLL	db	20,0,0
PRECTFRAME_VLD	db	12,19,0
PRECTFRAME_HLL	db	20,0,20,38,0
PRECTFRAME_HLD	db	12,53,7,73,0
endif

PRECTXCELL 	label word
	dw	offset PRECTTITLE_VSL
	dw	offset PRECTFRAME_VSL
	dw	fbputsl
	db	1,2,12,1
	dw	offset PRECTTITLE_VSD
	dw	offset PRECTFRAME_VSD
	dw	fbputsd
	db	1,2,38,1
	dw	offset PRECTTITLE_VSL
	dw	offset PRECTFRAME_HSL
	dw	fbputsl
	db	1,2,12,1
	dw	offset PRECTTITLE_VSD
	dw	offset PRECTFRAME_HSD
	dw	fbputsd
	db	1,2,38,1
ifdef __LFN__	; using long file names
	dw	offset PRECTTITLE_VLL
	dw	offset PRECTFRAME_VLL
	dw	fbputll
	db	1,2,18,1
	dw	offset PRECTTITLE_VLD
	dw	offset PRECTFRAME_VLD
	dw	fbputld
	db	1,2,38,1
	dw	offset PRECTTITLE_VLL
	dw	offset PRECTFRAME_HLL
	dw	fbputll
	db	1,2,18,1
	dw	offset PRECTTITLE_VSD
	dw	offset PRECTFRAME_HLD
	dw	fbputld
	db	1,2,78,1
endif
	dw	offset PRECTTITLE_VWL
	dw	offset PRECTFRAME_VWL
	dw	fbputlw
	db	1,2,38,1
	dw	offset PRECTTITLE_VWL
	dw	offset PRECTFRAME_VWL
	dw	fbputhw
	db	1,2,78,1
_DATA	ENDS

_DZIP	SEGMENT

prect_show proc
	push si
	mov si,ax
	xor ax,ax
	.if cflag & _C_WIDEVIEW && si != cpanel
	    jmp @F
	.endif
	.if !func(dlshow, [si.pn_dialog])
	    and [si.pn_flag],not _P_VISIBLE
	.endif
      @@:
	mov bx,si
	or ax,ax
	pop si
	ret
prect_show endp

prect_hide proc
	push si
	mov si,ax
	mov ax,[si.pn_flag]
	and ax,_P_VISIBLE
	.if !ZERO?
	    invoke dlclose, [si.pn_xl]
	    invoke dlhide, [si.pn_dialog]
	    mov ax,1
	.endif
	pop si
	ret
prect_hide endp

prect_close proc
	push si
	mov si,ax
	mov ax,[si.pn_flag]
	and ax,_P_VISIBLE
	.if !ZERO?
	    mov ax,si
	    call prect_hide
	    invoke dlclose, [si.pn_dialog]
	    mov ax,1
	.endif
	pop si
	ret
prect_close endp

prect_open proc pascal uses si di ; AX = panel
local	panel:word
local	rect:dword
local	index:word
local	xcell:word
local	xlrc:dword
local	dlwp:dword
	mov si,ax
	mov panel,ax
	call comhide
	mov di,[si.pn_flag]
	xor dx,dx		; x,y
	mov al,40		; cols
	mov ah,_scrrow		; rows
	mov cx,cflag
	mov bh,9		; panel size (rows)
    	.if !(cx & _C_COMMANDLINE)
	    inc ah		; rows++
    	.endif
    	.if cx & _C_MENUSLINE
	    inc dh		; y++
	    dec ah		; rows--
    	.endif
    	.if cx & _C_STATUSLINE
	    dec ah		; rows--
    	.endif
    	.if cx & _C_HORIZONTAL && !(cx & _C_WIDEVIEW)
	    shr ah,1		; rows / 2
	    dec bh
    	.endif
	mov bl,ah
	sub bl,bh		; rows - bh (size)
    	.if bl < config.c_panelsize
	    mov config.c_panelsize,bl
    	.endif
	sub ah,config.c_panelsize
    	.if cx & _C_HORIZONTAL
	    mov al,80		; cols = 80
     	    .if di & _P_PANELID && !(cx & _C_WIDEVIEW)
		add dh,ah 	; y += rows
     	    .endif
    	.elseif di & _P_PANELID && !(cx & _C_WIDEVIEW)
	    mov dl,40		; x = 40
    	.endif
	mov word ptr rect,dx
	mov word ptr rect+2,ax
	xor bx,bx
    	.if cx & _C_HORIZONTAL
	    mov bl,2
    	.endif
    	.if di & _P_DETAIL
	    inc bl
    	.endif
      ifdef __LFN__
	push bx
	mov bx,[si]
	test [bx.wp_flag],_W_LONGNAME
	pop bx
	.if !ZERO?
	    add bl,4
	.endif
      endif
	.if di & _P_WIDEVIEW
	  ifdef __LFN__
	    mov bl,8
	  else
	    mov bl,4
	  endif
	    .if cx & _C_HORIZONTAL
		inc bl
	    .endif
	.endif
	mov index,bx
	mov cx,ax
	mov ax,10 ; SIZE S_PRECT
	mul bl
	add ax,offset PRECTXCELL
	mov xcell,ax
	mov bx,ax
	mov ax,[bx+OFF_RECT+2]
	mov word ptr xlrc+2,ax
	mov ax,[bx+OFF_RECT]
	add ax,dx
	mov word ptr xlrc,ax
	mov bx,word ptr [si.pn_xl]
	mov word ptr [bx.xl_cpos],ax
	mov ax,word ptr xlrc+2
	mov dl,al
	mov word ptr [bx.xl_cpos+2],ax
	mov al,ch
	sub al,3
	mov [bx.xl_rows],al
	mov ah,00h
	mov al,cl
	div dl
	mov [bx.xl_cols],al
	mov bx,offset prect_a
	.if di & _P_PANELID
	    mov bx,offset prect_b
	.endif
	.if [bx.dl_flag] & _D_DOPEN
	    push bx
	    invoke dlclose, [si.pn_xl]
	    invoke dlclose, [si.pn_dialog]
	    pop bx
	.endif
	movmx [bx.dl_rect],rect
	mov al,at_background[B_Desktop]
	or al,at_foreground[F_Frame]
	.if func(dlopen, [si.pn_dialog], ax, 0)
	    xor ax,ax
	    mov word ptr rect,ax
	    mov bx,word ptr [si.pn_dialog]
	    les bx,[bx.dl_wp]
	    stoso dlwp,es,bx
	    mov cl,rect.rc_col
	    mov ch,0
	    add bx,cx
	    add bx,cx
	    mov ah,at_background[B_Desktop]
	    or ah,at_foreground[F_Panel]
	    mov al,' '
	    call @wcputw
	    .if di & _P_MINISTATUS
		mov al,2
		sub rect.rc_row,al
		mov bx,word ptr [si.pn_xl]
		sub [bx.xl_rows],al
		.if di & _P_DRVINFO
		    sub rect.rc_row,al
		    sub [bx.xl_rows],al
		    .if !(cflag & _C_HORIZONTAL)
			dec rect.rc_row
			dec [bx.xl_rows]
		    .endif
		.endif
		mov ah,at_background[B_Desktop]
		or ah,at_foreground[F_Frame]
		mov al,0
		invoke rcframe, rect, dlwp, word ptr rect+2, ax
	    .endif
	    movmx xlrc,rect
	    xor ax,ax
	    mov bx,xcell
	    mov bx,[bx+OFF_FRAME]
	    .repeat
		mov al,[bx]
		.break .if !al
		inc bx
		mov xlrc.rc_col,al
		mov al,[bx]
		inc bx
		mov xlrc.rc_x,al
		push bx
		mov al,12
		mov ah,at_background[B_Desktop]
		or ah,at_foreground[F_Frame]
		invoke rcframe, xlrc, dlwp, word ptr rect+2, ax
		pop bx
	    .until 0
	    mov bx,si
	    mov si,xcell
	    mov ax,[si+OFF_PROC]
	    mov [bx.pn_putfcb],ax
	    mov dx,ds
	    les bx,dlwp
	    mov cl,rect.rc_col
	    mov ch,cl
	    add ch,cl
	    mov ax,index
	    .if al < 9
		.if al == 7
		    add bx,80
		    mov ax,[si]
		    call @wcputs
		    mov ah,00h
		    mov al,ch
		    mov bx,word ptr dlwp
		    add bx,ax
		    add bx,18*2
		    mov ax,offset cp_name
		    call @wcputs
		    add bx,28*2
		    mov cx,4
		    mov ax,0020h
		    call @wcputw
		.else
		    .if al == 2 || al == 3 || al == 6
			mov ax,[si]
			call @wcputs
			add bx,250
			mov ax,[si]
			add ax,2
		    .else
			mov ax,[si]
		    .endif
		    call @wcputs
		.endif
	    .endif
	    les bx,dlwp
	    mov al,rect.rc_col
	    mov ah,0
	    mov dx,ax
	    inc ax
	    inc ax
	    add bx,ax
	    add bx,ax
	    mov byte ptr es:[bx],':'
	    mov byte ptr es:[bx+2],25
	    mov bx,panel
	    mov bx,word ptr [bx.pn_dialog]
	    push word ptr [bx.dl_rect+2]
	    xor ax,ax
	    push ax
	    pushm dlwp
	    mov al,[bx+6]
	    push ax
	    mov ah,at_background[B_Desktop]
	    or ah,at_foreground[F_Frame]
	    mov al,6
	    push ax
	    call rcframe
	    .if di & _P_MINISTATUS
		.if di & _P_DRVINFO
		    mov al,rect.rc_row
		    dec al
		    mul rect.rc_col
		    add ax,2
		    add ax,ax
		    les bx,dlwp
		    add bx,ax
		    mov cx,1
		    mov ax,001Fh
		    call @wcputw
		.else
		    mov al,rect.rc_row
		    dec al
		    mul rect.rc_col
		    add ax,2
		    add ax,ax
		    les bx,dlwp
		    add bx,ax
		    mov cx,1
		    mov ax,0007h
		    call @wcputw
		    mov al,rect.rc_col
		    sub al,5
		    mov ah,0
		    add ax,ax
		    add bx,ax
		    mov ax,001Fh
		    call @wcputw
		.endif
	    .else
		mov al,rect.rc_col
		mul rect.rc_row
		sub ax,3
		add ax,ax
		les bx,dlwp
		add bx,ax
		mov cx,1
		mov ax,001Eh
		call @wcputw
	    .endif
	    mov ax,panel
	    call prect_show
	.endif
	push ax
	call comshow
	pop ax
	ret
prect_open endp

prect_open_ab proc
	mov al,byte ptr cflag
	and al,_C_PANELID
	mov ax,offset spanela
	.if !ZERO?
	    mov ax,offset spanelb
	.endif
	mov cpanel,ax
	mov ax,offset spanela
	.if flaga & _P_VISIBLE
	    call prect_open
	.endif
	mov ax,offset spanelb
	.if flagb & _P_VISIBLE
	    call prect_open
	.endif
	ret
prect_open_ab endp

prect_clear proc pascal uses si di rect:dword, ptype:word
local	result:word
	xor ax,ax
	mov al,_scrcol
	add ax,ax
	mov si,ax
	mov al,[bp+4]
	cmp al,3
	jnb prect_clear_04
	add word ptr [bp+6],0201h
	sub word ptr [bp+8],0302h
	mov bx,[bp+6]
	call @getxyp
	mov di,bx
	xor ax,ax
	mov al,[bp+9]	; rect.rc_row
	mov bx,ax
	mov al,[bp+8]	; rect.rc_col
	mov dx,ax
	cld
	mov [bp-2],di
	mov cx,dx
	cmp byte ptr [bp+4],1
	jb prect_clear_07
	je prect_clear_05
	dec bx
	jz prect_clear_07
	mov ax,si
	mul bl
	add di,ax
	mov [bp-2],di
    prect_clear_03:
	sub di,si
	mov ax,es:[di]
	add di,si
	stosw
	dec cx
	jnz prect_clear_03
	mov cx,dx
	sub [bp-2],si
	mov di,[bp-2]
	dec bx
	jnz prect_clear_03
	mov bx,1
	jmp prect_clear_07
    prect_clear_04:
	ret
    prect_clear_05:
	dec bx
	jz prect_clear_07
    prect_clear_06:
	add di,si
	mov ax,es:[di]
	sub di,si
	stosw
	dec cx
	jnz prect_clear_06
	mov cx,dx
	add [bp-2],si
	mov di,[bp-2]
	dec bx
	jnz prect_clear_06
	inc bx
    prect_clear_07:
	mov ax,es:[di]
	cmp al,'³'
	jz prect_clear_08
	mov al,20h
	mov es:[di],ax
    prect_clear_08:
	add di,2
	dec cx
	jnz prect_clear_07
	add [bp-2],si
	mov di,[bp-2]
	mov cx,dx
	or bx,bx
	jz prect_clear_09
	dec bx
	jnz prect_clear_07
    prect_clear_09:
  ifdef __MOUSE__
	call mouseshow
  endif
	jmp prect_clear_04
prect_clear endp

;----------------------------------------------------------------------------

ypos	equ	[bp+4]
xpos	equ	[bp+4+2]
fblk	equ	[bp+4+4]

fbputsize proc
	mov ax,es:[bx.fb_flag]
	call fbcolor
	mov ch,al
	mov ax,offset format_10lu
	.if es:[bx.fb_flag] & _A_VOLID
	    mov	ch,at_foreground[F_Subdir]
	    or	ch,at_background[B_Desktop]
	    mov	ax,offset format_02lX
	.endif
	scputf@	dl, ypos, ch, 0, ax, es:[bx+6], es:[bx+8]
	ret
fbputsize endp

fbputsystem proc
	les bx,fblk
	mov al,es:[bx]
	.if al & (_A_HIDDEN or _A_SYSTEM)
	    call fbcolor
	    mov ah,al
	    mov al,'°'
	    scputw@ dl, ypos, 1, ax
	.endif
	ret
fbputsystem endp

fbputmax proc
	push cx
	push bx
	mov cx,1
	mov bl,al
	mov al,'¯'
	mov ah,at_foreground[F_Panel]
	or ah,at_background[B_Desktop]
	call @scputw
	pop bx
	pop cx
	ret
fbputmax endp

fbputdatetime proc
	push ax
	add ax,9
	invoke fbputtime, fblk, ax, ypos
	pop ax
	invoke fbputdate, fblk, ax, ypos
	ret
fbputdatetime endp

fbputdate proc pascal uses si di fb:dword, x:word, y:word
	les bx,fb
	mov di,es:[bx.fb_flag]
	mov ax,es:[bx.fb_date]
	mov si,ax
      ifdef __ROT__
	.if di & _A_ROOTDIR
	    or di,_A_SYSTEM
	    .if !(di & (_A_SUBDIR or _A_VOLID))
		mov ax,[si.ti_date]
		mov si,ax
	    .endif
	.endif
      endif
	shr ax,9
   	.if ax >= 20
	    sub ax,20
   	.else
	    add ax,80
   	.endif
	push ax
	mov ax,si
	shr ax,5
	and ax,000Fh
	push ax
	mov ax,si
	and ax,001Fh
	push ax
	mov ax,di
	call fbcolor
	mov ch,al
	mov ax,offset cp_datefrm
	mov cl,0
	mov bh,byte ptr y
	mov bl,byte ptr x
	call @scputf
	add sp,6
	ret
fbputdate endp

fbputtime proc pascal fb:dword, x:word, y:word
	les bx,fb
	mov ax,es:[bx.fb_time]
	shr ax,5
	and ax,003Fh
	push ax
	mov ax,es:[bx.fb_time]
	shr ax,11
	and ax,001Fh
	push ax
	mov ax,es:[bx.fb_flag]
      ifdef __ROT__
	.if ax & _A_ROOTDIR
	    or ax,_A_SYSTEM
	.endif
      endif
	call fbcolor
	mov ch,al
	mov cl,0
	mov ax,offset cp_timefrm
	mov bh,byte ptr y
	mov bl,byte ptr x
	call @scputf
	add sp,4
	ret
fbputtime endp

fbput83	proc pascal xl:word, xb:word, yb:word, at:word, fname:dword
	invoke strext, fname
	push ax
	mov cx,xl
	.if !ZERO?
	    sub ax,word ptr fname
	    .if al <= cl
		mov cl,al
	    .endif
	.endif
	mov bl,byte ptr xb
	mov bh,byte ptr yb
	mov ch,byte ptr at
	lodm fname
	call @scputs
	pop ax
	.if ax
	    inc ax
	    mov cl,3
	    add bl,byte ptr xl
	    inc bl
	    call @scputs
	.endif
	ret
fbput83 endp

fbputsl	proc pascal fb:dword, x:word, y:word
	les bx,fb
	mov ax,es:[bx.fb_flag]
	call fbcolor
	.if (es:[bx.fb_flag] & _A_UPDIR)
	    mov cl,0
	    mov ch,al
	    mov ax,bx
	    mov bl,byte ptr x
	    mov bh,byte ptr y
	    mov dx,es
	    add ax,fb_name
	    call @scputs
	.else
	    invoke fbput83, 8, x, y, ax, addr es:[bx.fb_name]
	    mov dx,x
	    add dx,8
	    call fbputsystem
	.endif
	ret
fbputsl	endp

fbputsd	proc pascal fb:dword, x:word, y:word
	invoke fbputsl, fb, x, y
	les bx,fb
	mov ax,es:[bx]
	.if (ax & _A_SUBDIR)
	    mov dx,ax
	    call fbcolor
	    mov ch,al
	    mov bl,byte ptr x
	    add bl,13
	    mov bh,byte ptr y
	    mov cl,0
	    mov ax,offset cp_subdir
	    .if dx & _A_UPDIR
		mov ax,offset cp_updir
	    .endif
	    mov dx,ds
	    call @scputs
	.else
	    mov dx,x
	    add dx,13
	    call fbputsize
	.endif
	mov ax,x
	add ax,24
	call fbputdatetime
	ret
fbputsd endp

ifdef __LFN__

fbputll proc pascal uses si di fb:dword, x:word, y:word
	push word ptr fb+2
	mov ax,word ptr fb
	add ax,fb_name
	mov di,ax
	push ax
	call strlen
	mov si,ax
	mov bx,word ptr fb
	mov ax,es:[bx]
	mov dx,ax
	call fbcolor
	mov ch,al
	mov ax,di
	mov di,dx
	mov cl,17
	mov bl,byte ptr x
	mov bh,byte ptr y
	mov dx,word ptr fb+2
	.if bl == 58
	    add cl,2
	.endif
	call @scputs
	mov al,bl
	add al,16
	.if si >= 18
	    .if al >= 74
		mov al,77
	    .endif
	    call fbputmax
	.endif
	add bl,17
	.if bl >= 74
	    mov bl,78
	.endif
	mov dl,bl
	call fbputsystem
	ret
fbputll endp

fbputld proc pascal uses si di fb:dword, x:word, y:word
	push word ptr fb+2
	mov ax,word ptr fb
	add ax,fb_name
	mov di,ax
	push ax
	call strlen
	mov si,ax
	mov bx,word ptr fb
	mov ax,es:[bx]
	mov cx,ax
	call fbcolor
	shl ax,8
	or si,ax
	mov bl,byte ptr x
	mov bh,byte ptr y
	.if cflag & _C_HORIZONTAL	; Long Horizontal Detail
	    .if cl & _A_UPDIR
		mov cx,si
		mov ax,di
		mov dx,word ptr fb+2
		call @scputs
		mov bl,54
		mov cl,0
		mov dx,ds
		mov ax,offset cp_updir
		call @scputs
	    .else
		push cx
		mov cx,si
		.if cl > 52
		    mov cl,51
		    mov al,52
		    call fbputmax
		.endif
		mov ax,di
		mov dx,word ptr fb+2
		call @scputs
		mov dx,52
		call fbputsystem
		pop ax
		.if ax & _A_SUBDIR
		    mov bl,54
		    mov bh,byte ptr y
		    mov cx,si
		    mov cl,0
		    mov dx,ds
		    mov ax,offset cp_subdir
		    call @scputs
		.else
		    mov dx,54
		    les bx,fb
		    call fbputsize
		.endif
	    .endif
	    mov ax,x
	    add ax,64
	    call fbputdatetime
	.else			; Long Vertical Detail
	    .if cx & _A_UPDIR
		mov cx,si
		mov ax,di
		mov dx,word ptr fb+2
		call @scputs
	    .elseif cx & _A_SUBDIR
		mov cx,si
		xor cl,cl
		add bl,19
		mov dx,ds
		mov ax,offset cp_subdir
		call @scputs
		sub bl,19
		mov cx,si
		.if cl > 17
		    mov cl,16
		    mov al,bl
		    add al,16
		    call fbputmax
		.endif
		mov ax,di
		mov dx,word ptr fb+2
		call @scputs
		mov dx,x
		add dx,17
		call fbputsystem
	    .else
		push bx
		mov bx,word ptr fb
		mov dx,x
		add dx,19
		call fbputsize
		mov ax,si
		mov al,ah
		les bx,fb
		invoke fbput83, 14, x, y, ax, addr es:[bx.fb_name]
		mov dx,x
		add dx,14
		call fbputsystem
		pop bx
		mov cx,si
		.if cl > 18
		    mov al,bl
		    add al,13
		    call fbputmax
		.endif
	    .endif
	    mov ax,x
	    add ax,30
	    invoke fbputdate, fb, ax, y
	.endif
	ret
fbputld endp

endif ; USE_IFSMGR

fbputlw proc pascal uses si di fb:dword, x:word, y:word
	push word ptr fb+2
	mov ax,word ptr fb
	add ax,fb_name
	mov di,ax
	push ax
	call strlen
	mov si,ax
	mov bx,word ptr fb
	mov ax,es:[bx]
	mov dx,ax
	call fbcolor
	mov ch,al
	mov ax,di
	mov di,dx
	mov cl,37
	mov bl,byte ptr x
	mov bh,byte ptr y
	mov dx,word ptr fb+2
	call @scputs
	mov al,bl
	add al,36
	.if si >= 37
	    call fbputmax
	.endif
	add bl,37
	mov dl,bl
	call fbputsystem
	ret
fbputlw endp

fbputhw proc pascal uses si di fb:dword, x:word, y:word
	push word ptr fb+2
	mov ax,word ptr fb
	add ax,fb_name
	mov di,ax
	push ax
	call strlen
	mov si,ax
	mov bx,word ptr fb
	mov ax,es:[bx]
	mov dx,ax
	call fbcolor
	mov ch,al
	mov ax,di
	mov di,dx
	mov cl,77
	mov bl,byte ptr x
	mov bh,byte ptr y
	mov dx,word ptr fb+2
	call @scputs
	mov al,bl
	add al,76
	.if si >= 77
	    call fbputmax
	.endif
	add bl,77
	mov dl,bl
	call fbputsystem
	ret
fbputhw endp

fbputfile proc pascal uses si di fb:dword, x:word, y:word
      ifdef __LFN__
	invoke fbputll, fb, x, y
      else
	invoke fbputsl, fb, x, y
      endif
	les bx,fb
	mov ax,es:[bx]
	mov si,ax
	call fbcolor
	mov ch,al
	lodm es:[bx.fb_size]
	mov bl,byte ptr x
	add bl,15
	mov bh,byte ptr y
	.if si & _A_SUBDIR
	    inc bl
	    mov cl,7
	    and si,_A_UPDIR
	    mov ax,offset cp_subdir+1
	    .if !ZERO?
		mov ax,offset cp_updir+1
	    .endif
	    mov dx,ds
	    call @scputs
	.else
	    mov cl,2
	    push bx
	    xor bx,bx
	    .while dx >= 15
		mov al,ah
		mov ah,dl
		shr ax,cl
		mov dl,0
		shr dx,cl
		or ah,dl
		mov dl,dh
		mov dh,0
		inc bx
	    .endw
	    mov cl,[bx+cp_strmega]
	    pop bx
	    push cx
	    push dx
	    push ax
	    mov ax,offset format_7luc
	    mov cl,0
	    call @scputf
	    add sp,6
	.endif
	mov ax,x
	add ax,24
	call fbputdatetime
	ret
fbputfile endp

_DZIP	ENDS

	END
