include	clib.inc
include	conio.inc
include	malloc.inc

PPROC	rcclose, rect:dword, fl:word, wp:dword
	mov	ax,fl
	and	ax,_D_DOPEN
	push	ax
	mov	ax,fl
	jz	rcclose_01
	test	ax,_D_ONSCR
	jz	@F
	invoke	rchide, rect, fl, wp
	mov	ax,fl
    @@:
	test	ax,_D_MYBUF
	jnz	rcclose_01
	invoke	free, wp
    rcclose_01:
	pop	ax
	ret
PEND	rcclose

	END
