include	clib.inc
include	conio.inc
include	tinfo.inc

	extrn	tiseto:near
	extrn	tiputs:near
	extrn	tievent:near
  ifdef __CLIP__
	extrn	ticlipevent:near
  endif

PPROC	tihndlevent, ti:word, event:word
	push	di
	mov	di,tinfo
	mov	ax,ti
	mov	tinfo,ax
	call	tiseto
	call	tiputs
	mov	ax,event
	or	ax,ax
	jnz	@F
	call	tgetevent
	mov	event,ax
    @@:
  ifdef __CLIP__
	call	ticlipevent
  endif
	call	tievent
	push	ax
	call	tiseto
	call	tiputs
	pop	dx
	xor	ax,ax
	cmp	dx,_TI_RETEVENT
	jne	@F
	mov	ax,event
    @@:
	mov	tinfo,di
	pop	di
	ret
PEND	tihndlevent

	END
