include	clib.inc
include	mouse.inc

PPROC	mousewait, X:word, Y:word, L:word
  ifdef __MOUSE__
	push	si
	mov	si,X
	jmp	mousewait_01
    mousewait_00:
	call	mousex
	cmp	ax,si
	jl	mousewait_end
	mov	dx,si
	add	dx,L
	cmp	ax,dx
	jg	mousewait_end
	call	mousey
	cmp	ax,Y
	jne	mousewait_end
    mousewait_01:
	call	mousep
	jnz	mousewait_00
    mousewait_end:
	pop	si
  endif
	ret
PEND	mousewait

	END
