include	doszip/doszip.inc
include	conio.inc
include	errno.inc
include tinfo.inc
include malloc.inc

	public	apiopen
	public	apiclose
	public	apiupdate
	public	cmegaline
	public	cmuserscreen
	public	apishow
	public	apihide

	extrn	com_info:S_TINFO

_DZIP	SEGMENT

apiidle PROC DIST
	.if cflag & _C_MENUSLINE
	    call tupddate
	    call tupdtime
	.endif
	call trace
	xor ax,ax
	ret
apiidle ENDP

apimode PROC
	mov ax,3
	int 10h
	call _screct
apimode	ENDP

apiega	PROC
	and cflag,not _C_EGALINE
	.if _scrrow > 24
	    or cflag,_C_EGALINE
	.endif
	ret
apiega	ENDP

apiopen	PROC
	call consinit
	.if console & CON_IMODE && \
	    !(_scrcol == 80 && (_scrrow == 24 || _scrrow == 49))
	    call apimode
	.endif
	call cursory
	inc ax
	mov com_info.ti_ypos,ax
	.if console & CON_IMODE
	    mov al,24
	    .if cflag & _C_EGALINE
		mov al,49
	    .endif
	    call conssetl
	.endif
	mov al,_scrrow
	mov Statusline_Y,al
	.if cflag & _C_STATUSLINE
	    dec al
	.endif
    	mov dx,com_info.ti_ypos
	.if dl < al
	    mov al,dl
	.endif
    	mov Commandline_Y,al
	mov byte ptr com_info.ti_ypos,al
	invoke rsopen,IDD_Commandline
	stom DLG_Commandline
	invoke rsopen,IDD_DZMenusline
	stom DLG_Menusline
	.if cflag & _C_MENUSLINE
	    invoke dlshow, dx::ax
	.endif
    	invoke rsopen,IDD_Statusline
	stom DLG_Statusline
	.if cflag & _C_STATUSLINE
	    invoke dlshow, dx::ax
	.endif
    	call comshow
	fpmov tupdate,apiidle
	call apiidle
	ret
apiopen	ENDP

apihide	PROC
	invoke	getcursor, addr dlgcursor
	mov	bx,panela
	mov	bx,word ptr [bx.pn_dialog]
	mov	al,[bx]
	mov	dlgflags,al
	push	ds
	push	bx
	mov	bx,panelb
	mov	bx,word ptr [bx.pn_dialog]
	mov	al,[bx]
	mov	dlgflags[1],al
	push	ds
	push	bx
	les	bx,DLG_Statusline
	mov	al,es:[bx]
	mov	dlgflags[2],al
	push	es
	push	bx
	les	bx,DLG_Commandline
	mov	al,es:[bx]
	mov	dlgflags[3],al
	push	es
	push	bx
	mov	al,es:[bx+5]
	invoke	gotoxy, 0, ax
	les	bx,DLG_Menusline
	mov	al,es:[bx]
	mov	dlgflags[4],al
	invoke	dlhide, es::bx
	call	dlhide
	call	dlhide
	call	dlhide
	call	dlhide
	ret
apihide	ENDP

apishow	PROC
	push	dx
	push	ax
	invoke	free, console_wp
	call	consinit
	invoke	setcursor, dlgcursor
	test	dlgflags,_D_ONSCR
	jz	@F
	mov	bx,panela
	invoke	dlshow, [bx.pn_dialog]
    @@:	test	dlgflags[1],_D_ONSCR
	jz	@F
	mov	bx,panelb
	invoke	dlshow, [bx.pn_dialog]
    @@:	test	dlgflags[2],_D_ONSCR
	jz	@F
	invoke	dlshow, DLG_Statusline
    @@:	test	dlgflags[3],_D_ONSCR
	jz	@F
	invoke	dlshow, DLG_Commandline
    @@:	test	dlgflags[4],_D_ONSCR
	jz	@F
	invoke	dlshow, DLG_Menusline
    @@:	pop	ax
	pop	dx
	ret
apishow	ENDP

apiclose PROC
	invoke	dlclose, DLG_Menusline
	invoke	dlclose, DLG_Commandline
	invoke	dlclose, DLG_Statusline
	call	consexit
	ret
apiclose ENDP

apiupdate PROC
	call comhide
	invoke dlhide, DLG_Menusline
	invoke dlhide, DLG_Statusline
	call redraw_panels
	mov al,_scrrow
	les bx,DLG_Statusline
	mov es:[bx+5],al
	.if cflag & _C_STATUSLINE
	   invoke dlshow, DLG_Statusline
	.endif
	.if cflag & _C_MENUSLINE
	    invoke dlshow, DLG_Menusline
	.endif
	call comshow
	ret
apiupdate ENDP

cmegaline PROC DIST
	mov ax,49
	.if cflag & _C_EGALINE
	    mov al,24
	.endif
	call conssetl
	call apiega
	call apiupdate
	ret
cmegaline ENDP

cmuserscreen PROC DIST
	.if _scrcol == 80
	    call consuser
	.else
	    call notsup
	.endif
	ret
cmuserscreen ENDP

_DZIP	ENDS

_DATA	SEGMENT

dlgflags	db 5 dup(?)
dlgcursor	dd ?

Commandline_RC	dw 000B0h,00010h,00000h
		db 0
Commandline_Y	db 23,80,1
		dw 50F0h
		db 07h
		dw 50F0h
		db ' '
IDD_Commandline	dd DGROUP:Commandline_RC

Statusline_RC	dw 000B0h,00450h,00000h
		db 0
Statusline_Y	db 24,80,1
		dw 03F3Bh,0F03Fh,03B07h
		dw 03F3Fh,006F0h,03F3Bh,0F03Fh,03B07h,03F3Fh,007F0h,03F3Bh
		dw 0F03Fh,03B07h,03F3Fh,007F0h,03F3Bh,0F03Fh,03B08h,03F3Fh
		dw 006F0h,0F03Bh,03F03h,005F0h,0203Bh,03146h,04820h,06C65h
		dw 02070h,04620h,02032h,06552h,0206Eh,04620h,02033h,06956h
		dw 07765h,02020h,03446h,04520h,06964h,02074h,04620h,02035h
		dw 06F43h,07970h,02020h,03646h,04D20h,0766Fh,02065h,04620h
		dw 02037h,06B4Dh,06964h,02072h,04620h,02038h,06544h,0206Ch
		dw 04620h,03031h,04520h,06978h,02074h
IDD_Statusline	dd DGROUP:Statusline_RC

_DATA	ENDS

	END
