include doszip/doszip.inc
include dir.inc
include dos.inc
include io.inc
include iost.inc
include string.inc
include	conio.inc
include	mouse.inc
include	errno.inc
ifdef __TE__
include	tinfo.inc
include	stdio.inc
include	keyb.inc
include	format.inc
include	malloc.inc
endif
	public	cmsystem
	public	cmscreen
	public	cmpanel
	public	cmconfirm
	public	cmcompression
	public	cmoptions
ifdef __TE__
	public	teoption
	extrn	IDD_TEOptions:dword
endif
	extrn	ifsmgr:byte

_DATA	SEGMENT

cf_panel	db	0
cf_panel_upd	dw	0
cp_cmdreload	db	'ECHO.',0
cp_pal		db	'*.pal',0

color_Mono	db	00h,00h,00h,00h,00h,70h,70h,00h
		db	0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh
		db	0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh
		db	0,1,2,3,4,5,20,7,56,57,58,59,60,61,62,63

color_Black	db	00h,00h,00h,00h,00h,10h,10h,00h
		db	07h,0Ah,0Fh,0Bh,0Fh,07h,08h,07h
		db	08h,07h,07h,07h,0Fh,0Ah,0Bh,0Bh
		db	0,1,2,3,4,5,20,7,56,57,58,59,60,61,62,63

color_Blue 	db	00h,10h,70h,70h,40h,30h,30h,70h
		db	00h,0Ah,0Fh,0Bh,0Fh,07h,08h,07h
		db	08h,07h,00h,00h,0Fh,0Ah,0Fh,0Fh
		db	0,1,2,3,4,5,20,7,56,57,58,59,60,61,62,63

color_Navy 	db	00h,10h,20h,30h,40h,50h,60h,70h
		db	00h,0Dh,0Fh,09h,0Fh,07h,08h,07h
		db	08h,07h,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh
		db	0,136,7,7,4,63,3,7,56,59,0,0,4,3,63,63

_DATA	ENDS

_DZIP	SEGMENT

cmsystem PROC DIST PASCAL
local	DLG_DZSystemOptions:DWORD
	push	si
	push	di
	invoke	rsopen, IDD_DZSystemOptions
	jz	cmsystem_end
	stom	DLG_DZSystemOptions
	mov	cx,_O_FLAGB
	mov	ax,console
	test	ax,CON_IMODE
	jz	@F
	or	es:[bx+8*16],cl
    @@:
	test	ax,CON_REVGA
	jz	@F
	or	es:[bx+9*16],cl
    @@:
	mov	ax,cflag
	test	ax,_C_SAVEHISTORY
	jnz	@F
	or	es:[bx+10*16],cl
    @@:
	test	ax,_C_ESCUSERSCR
	jz	@F
	or	es:[bx+11*16],cl
    @@:
	mov	ax,console
	invoke	tosetbitflag, es:[bx.dl_object], 7, _O_FLAGB, ax::ax
	invoke	dlinit, DLG_DZSystemOptions
	invoke	rsevent, IDD_DZSystemOptions, DLG_DZSystemOptions
	mov	si,ax
	invoke	togetbitflag, es:[bx.dl_object], 11, _O_FLAGB
	invoke	dlclose, DLG_DZSystemOptions
	mov	ax,si
	or	ax,ax
	jz	cmsystem_end
	mov	ax,dx
	mov	dx,cflag
	and	dx,not (_C_SAVEHISTORY or _C_ESCUSERSCR)
    .if !(ah & 2)	; Auto Delete History
	or	dx,_C_SAVEHISTORY
    .endif
    .if (ah & 4)	; Use Esc for user screen
	or	dx,_C_ESCUSERSCR
    .endif
	mov	cflag,dx
	mov	dx,console
	and	dx,not 307Fh
    .if (ah & 1)	; Restore VGA palette on exit
	or	dx,CON_REVGA
    .endif
    .if (al & 80h)	; Init screen mode on startup
	or	dx,CON_IMODE
    .endif
	and	al,3Fh
	or	dl,al
	mov	console,dx
  ifdef __MOUSE__
	test	dl,CON_MOUSE
	jz	cmsystem_mouse
	call	mouseoff
	call	mouseinit
	call	mouseon
  endif
	jmp	cmsystem_lfn
    cmsystem_mouse:
  ifdef __MOUSE__
	call	mouseoff
	mov	al,0
	call	mouseset
  endif
    cmsystem_lfn:
  ifdef __LFN__
	mov	dl,_ifsmgr
	test	byte ptr console,CON_IOLFN
	jnz	@F
  endif
	xor	ax,ax
  ifdef __LFN__
	mov	_ifsmgr,al
  endif
	and	path_a.wp_flag,not _W_LONGNAME
	and	path_b.wp_flag,not _W_LONGNAME
	jmp	cmsystem_cf
    @@:
  ifdef __LFN__
	cmp	ifsmgr,0
	je	cmsystem_nolfn
	mov	al,ifsmgr
	mov	_ifsmgr,al
	or	path_a.wp_flag,_W_LONGNAME
	or	path_b.wp_flag,_W_LONGNAME
	cmp	dl,al
	je	cmsystem_exit
  endif
    cmsystem_cf:
	cmp	cf_panel,1
	jne     cmsystem_updpn
	mov	cf_panel_upd,1
	jmp	cmsystem_exit
    cmsystem_nolfn:
	or	dx,dx
	jz	cmsystem_exit
	jmp	cmsystem_cf
    cmsystem_updpn:
	call	redraw_panels
    cmsystem_exit:
	mov	ax,1
    cmsystem_end:
	pop	di
	pop	si
	ret
cmsystem ENDP

ID_MEUSLINE	=	1*16
ID_COMMANDLINE	=	2*16
ID_STAUSLINE	=	3*16
ID_USEDATE	=	4*16
ID_USETIME	=	5*16
ID_USECOLOR	=	6*16

event_usecolor PROC DIST
	les	bx,tdialog
	push	word ptr es:[bx+ID_USECOLOR]
	call	dlcheckevent
	pop	dx
	push	ax
	les	bx,tdialog
	mov	ax,es:[bx+ID_USECOLOR]
	and	ax,_O_FLAGB
	and	dx,_O_FLAGB
	cmp	ax,dx
	je	event_usecolor_end
	cmp	ax,_O_FLAGB
	jne	event_usecolor_reset
	or	byte ptr console,CON_COLOR
	push	ds
	push	offset at_palett
	call    loadpal
	jmp	event_usecolor_end
    event_usecolor_reset:
	call	resetpal
	and	byte ptr console,not CON_COLOR
    event_usecolor_end:
	pop	ax
	ret
event_usecolor ENDP

event_reload PROC DIST
	push	ds
	push	offset cp_cmdreload
	call	command
	mov	ax,_C_ESCAPE
	ret
event_reload ENDP

event_loadcolor PROC DIST
	push	si
	invoke	wgetfile,addr cp_pal,3
	jz	event_loadcolor_end
	push	ax
	push	ax
	push	ds
	push	offset at_background
	push	size S_COLOR
	call	osread
	mov	si,ax
	call	close
	mov	ax,_C_NORMAL
	cmp	si,size S_COLOR
	jne	event_loadcolor_end
	call	event_reload
    event_loadcolor_end:
	pop	si
	ret
event_loadcolor ENDP

event_savecolor PROC DIST
	invoke	wgetfile,addr cp_pal,2
	jz	event_savecolor_end
	push	ax
	push	ax
	push	ds
	push	offset at_background
	push	size S_COLOR
	call	oswrite
	call	close
    event_savecolor_end:
	mov	ax,_C_NORMAL
	ret
event_savecolor ENDP

ifdef __AT__

event_editat PROC DIST
	call	editattrib
	or	ax,ax
	jnz	event_reload
	mov	ax,_C_NORMAL
	ret
event_editat ENDP

event_editpal PROC DIST
	call	editpal
	mov	ax,_C_NORMAL
	ret
event_editpal ENDP

endif

event_standard PROC DIST
	les	bx,tdialog
	mov	ax,es:[bx+4]
	add	ax,0B0Ch
	mov	bx,word ptr IDD_DZDefaultColor
	mov	[bx+6],ax
	invoke	rsmodal, ds::bx
	cmp	ax,4
	ja	event_standard_end
	je	event_standard_Mono
	cmp	ax,3
	je	event_standard_Black
	cmp	ax,1
	je	event_standard_Blue
	ja	event_standard_Navy
    event_standard_end:
	mov	ax,1
	ret
    event_standard_Navy:
	mov	ax,offset color_Navy
	or 	byte ptr console,CON_COLOR
	jmp	event_standard_set
    event_standard_Blue:
	call	resetpal
	mov	ax,offset color_Blue
	jmp	event_standard_set
    event_standard_Black:
	call	resetpal
	mov	ax,offset color_Black
	jmp	event_standard_set
    event_standard_Mono:
	mov	ax,offset color_Mono
    event_standard_set:
	invoke	memcpy, addr at_background, ds::ax, 40
	jmp	event_reload
event_standard ENDP

cmscreen PROC DIST
	push	si
	invoke	rsopen, IDD_DZScreenOptions
	jz	cmscreen_end
	push	dx
	push	ax
	pushm	IDD_DZScreenOptions
	push	dx
	push	ax
	push	dx
	push	ax
	mov	dl,_O_FLAGB
	mov	ax,cflag
	test	ax,_C_MENUSLINE
	jz	cmscreen_com?
	or	es:[bx+ID_MEUSLINE],dl
    cmscreen_com?:
	test	ax,_C_COMMANDLINE
	jz	cmscreen_stl?
	or	es:[bx+ID_COMMANDLINE],dl
    cmscreen_stl?:
	test	ax,_C_STATUSLINE
	jz	cmscreen_date?
	or	es:[bx+ID_STAUSLINE],dl
    cmscreen_date?:
	mov	ax,console
	test	ax,CON_UDATE
	jz	cmscreen_time?
	or	es:[bx+ID_USEDATE],dl
    cmscreen_time?:
	test	ax,CON_UTIME
	jz	cmscreen_color?
	or	es:[bx+ID_USETIME],dl
    cmscreen_color?:
	test	al,CON_COLOR
	jz	cmscreen_event
	or	es:[bx+ID_USECOLOR],dl
    cmscreen_event:
  ifdef LPROG
	mov	ax,cs
	mov	es:[bx+TO_OPROC+11*16+2],ax
	mov	es:[bx+TO_OPROC+10*16+2],ax
	mov	es:[bx+TO_OPROC+9*16+2],ax
	mov	es:[bx+TO_OPROC+8*16+2],ax
	mov	es:[bx+TO_OPROC+7*16+2],ax
	mov	es:[bx+TO_OPROC+6*16+2],ax
  endif
	mov	word ptr es:[bx+TO_OPROC+6*16],offset event_usecolor
  ifdef __AT__
	mov	word ptr es:[bx+TO_OPROC+7*16],offset event_editpal
	mov	word ptr es:[bx+TO_OPROC+8*16],offset event_editat
  else
	or	word ptr es:[bx+TO_OFLAG+7*16],_O_STATE
	or	word ptr es:[bx+TO_OFLAG+8*16],_O_STATE
  endif
	mov	word ptr es:[bx+TO_OPROC+9*16],offset event_standard
	mov	word ptr es:[bx+TO_OPROC+10*16],offset event_loadcolor
	mov	word ptr es:[bx+TO_OPROC+11*16],offset event_savecolor
	call	dlinit
	call	rsevent
	mov	si,ax
	push	es
	add	bx,16
	push	bx
	push	6
	push	_O_FLAGB
	call	togetbitflag
	call	dlclose
	mov	ax,si
	mov	si,cflag
	or	ax,ax
	jnz	cmscreen_bits
	jmp	cmscreen_exit
  cmscreen_bits:
  	mov	ax,dx
	mov	dx,console
	and	dx,not (CON_UTIME or CON_UDATE or CON_COLOR)
	test	al,08h
	jz	cmscreen_time
	or	dx,CON_UDATE
    cmscreen_time:
	test	al,10h
	jz      cmscreen_color
	or	dx,CON_UTIME
    cmscreen_color:
	test	al,20h
	jz      cmscreen_menus
	or	dx,CON_COLOR
    cmscreen_menus:
	and	si,not (_C_MENUSLINE or _C_STATUSLINE or _C_COMMANDLINE)
	test	al,01h
	jz      cmscreen_com
	or	si,_C_MENUSLINE
    cmscreen_com:
	test	al,02h
	jz      cmscreen_stl
	or	si,_C_COMMANDLINE
    cmscreen_stl:
	test	al,04h
	jz      cmscreen_cons
	or	si,_C_STATUSLINE
    cmscreen_cons:
	cmp	console,dx
	je	cmscreen_flag
	mov	console,dx
	test	cflag,_C_MENUSLINE
	jz	cmscreen_flag
	mov	cx,8
	mov	ax,' '
	mov	bx,72
	test	dx,CON_UTIME
	jnz	cmscreen_date
	call	@scputw
    cmscreen_date:
	test	dx,CON_UDATE
	jnz	cmscreen_flag
	mov	bl,63
	call	@scputw
    cmscreen_flag:
	cmp	si,cflag
	je	cmscreen_end
	mov	cflag,si
	cmp	cf_panel,1
	jne	cmscreen_upd
	pushm	tdialog
	call	dlhide
    cmscreen_upd:
	call	apiupdate
	cmp	cf_panel,1
	jne	cmscreen_exit
	pushm	tdialog
	call	dlshow
    cmscreen_exit:
	mov	ax,_C_ESCAPE
	cmp	mainswitch,1
	je	cmscreen_end
	mov	ax,_C_NORMAL
    cmscreen_end:
	pop	si
	ret
cmscreen ENDP

cmpanel	PROC DIST
	push	si
	invoke	rsopen, IDD_DZPanelOptions
	jz	cmpanel_end
	push	dx
	push	ax
	pushm	IDD_DZPanelOptions
	push	dx
	push	ax
	push	dx
	push	ax
	mov	dl,_O_FLAGB
	mov	ax,cflag
	test	ax,_C_INSMOVDN
	jz	cmpanel_select_sub
	or	es:[bx+1*16],dl
    cmpanel_select_sub:
	test	ax,_C_SELECTDIR
	jz	cmpanel_sort_sub
	or	es:[bx+2*16],dl
    cmpanel_sort_sub:
	test	ax,_C_SORTDIR
	jz	cmpanel_clr
	or	es:[bx+3*16],dl
    cmpanel_clr:
	test	ax,_C_CDCLRDONLY
	jz	cmpanel_dlg
	or	es:[bx+4*16],dl
    cmpanel_dlg:
	call	dlinit
	call	rsevent
	mov	si,ax
	push	es
	push	4+16
	push	4
	push	_O_FLAGB
	call	togetbitflag
	call	dlclose
	mov	ax,si
	or	ax,ax
	jz	cmpanel_end
	mov	ax,dx
	and	path_a,not _W_SORTSUB
	and	path_b,not _W_SORTSUB
	mov	dx,cflag
	and	dx,not (_C_INSMOVDN or _C_SELECTDIR or _C_SORTDIR or _C_CDCLRDONLY)
	test	al,01h
	jz	cmpanel_select_sub?
	or	dx,_C_INSMOVDN
    cmpanel_select_sub?:
	test	al,02h
	jz	cmpanel_sort?
	or	dx,_C_SELECTDIR
    cmpanel_sort?:
	test	al,04h
	jz	cmpanel_clr?
	or	dx,_C_SORTDIR
	or	path_a,_W_SORTSUB
	or	path_b,_W_SORTSUB
    cmpanel_clr?:
	test	al,08h
	jz	cmpanel_set
	or	dx,_C_CDCLRDONLY
    cmpanel_set:
	cmp     cflag,dx
	je	cmpanel_one
	mov	cflag,dx
	cmp	cf_panel,1
	jne     cmpanel_upd
	mov	cf_panel_upd,1
	jmp	cmpanel_one
    cmpanel_upd:
	call	redraw_panels
    cmpanel_one:
	mov	ax,1
    cmpanel_end:
	pop	si
	ret
cmpanel	ENDP

cmconfirm PROC DIST
	push	si
	invoke	rsopen, IDD_DZConfirmations
	jz	cmconfirm_end
	push	dx
	push	ax
	pushm	IDD_DZConfirmations
	push	dx
	push	ax
	push	dx
	push	ax
	push	dx
	add	ax,16
	push	ax
	push	7
	push	_O_FLAGB
	push	ax
	mov	al,config.c_confirm
	push	ax
	call	tosetbitflag
	call	dlinit
	call	rsevent
	mov	si,ax
	push	es
	push	4+16
	push	7
	push	_O_FLAGB
	call	togetbitflag
	call	dlclose
	or	si,si
	jz	cmconfirm_end
	mov	config.c_confirm,dl
    cmconfirm_end:
	xor	ax,ax
	pop	si
	ret
cmconfirm ENDP

cmcompression PROC DIST
	invoke	rsopen, IDD_DZCompression
	jz	compression_end
	push	dx
	push	ax
	pushm	IDD_DZCompression
	push	dx
	push	ax
	push	dx
	push	ax
	mov	ah,0
	mov	al,compresslevel
	cmp	al,9
	jna	compression_level
	mov	al,6
	mov	compresslevel,al
    compression_level:
	inc	ax
	shl	ax,4
	push	bx
	add	bx,ax
	or	es:[bx.dl_flag],_O_RADIO
	pop	bx
	test	compressflag,_C_ZINCSUBDIR
	jz	compression_event
	or	es:[bx.dl_flag+11*16],_O_FLAGB
    compression_event:
	call	dlinit
	call	rsevent
	or	ax,ax
	jz	compression_end
	xor	ax,ax
	test	es:[bx.dl_flag+11*16],_O_FLAGB
	jz	compression_flag
	or	al,_C_ZINCSUBDIR
    compression_flag:
	mov	compressflag,al
	xor	ax,ax
    compression_loop:
	add	bx,SIZE S_TOBJ
	test	es:[bx.dl_flag],_O_RADIO
	jnz	compression_lev
	inc	ax
	cmp	ax,10
	jb	compression_loop
	mov	al,6
    compression_lev:
	mov	compresslevel,al
    compression_end:
	call	dlclose
	ret
cmcompression ENDP

ifdef __TE__

telinesize PROC
	push	dx
	xor	cx,cx
	mov	dx,TIMINLINE
	and	al,0F0h
	cmp	ax,dx
	jb	telinesize_min
	cmp	ax,TIMAXLINE
	ja	telinesize_max
    telinesize_inc:
	inc	cx
	shl	ax,1
	jnc	telinesize_inc
	dec	cx
	mov	ax,8000h
	shr	ax,cl
	cmp	ax,dx
	ja	telinesize_end
	mov	ax,dx
    telinesize_end:
	pop	dx
	ret
    telinesize_min:
	mov	ax,TIMAXLINE
	jmp	telinesize_inc
    telinesize_max:
	mov	ax,TIMAXLINE
	jmp	telinesize_inc
telinesize ENDP

tememoryset PROC
	push	tepages
	mov	cx,bx
	mov	ax,offset format_u
	mov	dx,es:[bx+6*16+TO_SDATA]
	mov	bx,es:[bx+6*16+TO_ODATA]
	call	@sprintf
	push	telsize
	mov	ax,offset format_u
	mov	bx,cx
	mov	bx,es:[bx+7*16+TO_ODATA]
	call	@sprintf
	add	sp,4
	mov	bx,cx
	ret
tememoryset ENDP

tememoryupd PROC
	push	si
	push	di
	push	bp
	mov	di,bx
	push	es
	push	es:[di+6*16+TO_ODATA]
	call	strtol
	mov	si,ax
	push	es
	push	es:[di+7*16+TO_ODATA]
	call	strtol
	call	telinesize
	mov	bp,ax
	push	ax
	mov	ax,offset format_u
	mov	dx,es
	mov	bx,es:[di+7*16+TO_ODATA]
	call	@sprintf
	add	sp,2
    tememoryupd_page:
	cmp	si,EMSMINPAGES
	ja	tememoryupd_emm
	mov	si,EMSMINPAGES
    tememoryupd_emm:
	push	es
	call	emminit
	pop	es
	jz	tememoryupd_convensional
    tememoryupd_nolines:
	mov	bx,si
	dec	cx
	shl	bx,cl
	mov	ax,EMMPAGE
	mul	si
	mov	cx,dx
	mov	si,bx
	mov	bx,ax
	xor	dx,dx
	mov	ax,EMMPAGE
	or	si,si
	jnz	tememoryupd_put
	mov	si,64
	mov	tepages,si
	mov	telsize,TIMINLINE
	mov	bx,di
	call	tememoryset
	mov	cx,8
	jmp	tememoryupd_nolines
    tememoryupd_convensional:
	xor	si,si
	mov	ax,'0'
	mov	bx,es:[di+6*16+TO_ODATA]
	mov	es:[bx],ax
	xor	ax,ax
	mov	dx,4
	div	bp
	mov	si,ax
	xor	ax,ax
	mov	dx,4
	mov	cx,ax
	mov	bx,ax
    tememoryupd_put:
	push	es
	push	di
	push	0
	push	si
	push	dx
	push	ax
	push	cx
	push	bx
	mov	bx,es:[di+4]
	add	bx,0D15h
	xor	cx,cx
	mov	ax,offset format_8ld
	call	@scputf
	add	sp,4
	inc	bh
	mov	ax,offset format_8ld
	call	@scputf
	add	sp,4
	inc	bh
	mov	ax,offset format_8ld
	call	@scputf
	add	sp,4
	call	dlinit
	xor	ax,ax
	pop	bp
	pop	di
	pop	si
	ret
tememoryupd ENDP

tememory_event PROC DIST
	call	dlteditevent
	cmp	ax,KEY_ENTER
	jne	tememory_event_end
	les	bx,tdialog
	call	tememoryupd
    tememory_event_end:
	ret
tememory_event ENDP

teoption PROC DIST
	push	si
	push	di
	invoke	rsopen, IDD_TEOptions
	jz	teoption_end
	push	dx
	push	ax
	pushm	IDD_TEOptions
	push	dx
	push	ax
	push	dx
	push	ax
	call	tememoryset
	mov	es:[bx+6*16+TO_OPROC],offset tememory_event
	mov	es:[bx+7*16+TO_OPROC],offset tememory_event
	LMOV	es:[bx+6*16+TO_OPROC+2],cs
	LMOV	es:[bx+7*16+TO_OPROC+2],cs
	add	bx,SIZE S_DOBJ
	push	es
	push	bx
	push	5
	push	_O_FLAGB
	mov	ax,teflag
	mov	al,ah
	push	ax
	push	ax
	call	tosetbitflag
	call	dlshow
	call	tememoryupd
	call	rsevent
	or	ax,ax
	jz	teoption_end
	push	es
	add	bx,SIZE S_DOBJ
	push	bx
	push	5
	push	_O_FLAGB
	call	togetbitflag
	mov	byte ptr teflag+1,al
	push	es
	push	es:[bx+5*16+TO_ODATA]
	push	es
	push	es:[bx+6*16+TO_ODATA]
	call	strtol
	call	telinesize
	mov	telsize,ax
	call	strtol
	cmp	ax,EMSMINPAGES
	jb	teoption_end
	mov	tepages,ax
    teoption_set:
	mov	ax,1
    teoption_end:
	call	dlclose
	mov	ax,dx
	pop	di
	pop	si
	ret
teoption ENDP

endif

cmoptions PROC DIST
	push	si
	mov	cf_panel,1
	mov	cf_panel_upd,0
	invoke	rsopen, IDD_DZConfiguration
	jz	cmoptions_03
	push	dx
	push	ax
	pushm	IDD_DZConfiguration
	push	dx
	push	ax
	push	dx
	push	ax
	LMOV	ax,cs
	LMOV	word ptr es:[bx+TO_OPROC+1*16+2],ax
	LMOV	word ptr es:[bx+TO_OPROC+2*16+2],ax
	LMOV	word ptr es:[bx+TO_OPROC+3*16+2],ax
	LMOV	word ptr es:[bx+TO_OPROC+5*16+2],ax
	LMOV	word ptr es:[bx+TO_OPROC+6*16+2],ax
  ifdef __TE__
	LMOV	word ptr es:[bx+TO_OPROC+4*16+2],ax
	mov	word ptr es:[bx+TO_OPROC+4*16],offset teoption
  else
	LMOV	word ptr es:[bx+TO_OPROC+4*16+2],seg _TEXT
	mov	word ptr es:[bx+TO_OPROC+4*16],offset notsup
  endif
	mov	word ptr es:[bx+TO_OPROC+5*16],offset cmconfirm
	mov	word ptr es:[bx+TO_OPROC+6*16],offset cmcompression
	mov	word ptr es:[bx+TO_OPROC+1*16],offset cmsystem
	mov	word ptr es:[bx+TO_OPROC+2*16],offset cmscreen
	mov	word ptr es:[bx+TO_OPROC+3*16],offset cmpanel
	test	cflag,_C_AUTOSAVE
	jz	@F
	or	byte ptr es:[bx+7*16],_O_FLAGB
    @@:
	call	dlinit
	call	rsevent
	mov	si,es:[bx+7*16]
	call	dlclose
	mov	cf_panel_upd,0
	add	dx,cf_panel_upd
	jz	cmoptions_03
	and	cflag,not _C_AUTOSAVE
	test	si,_O_FLAGB
	jz	@F
	or	cflag,_C_AUTOSAVE
    @@:
	call	redraw_panels
    cmoptions_03:
	mov	cf_panel,0
	pop	si
	ret
cmoptions ENDP

_DZIP	ENDS

	END
