include	clib.inc

PPROC	rcinside, dlrc:word, dlyx:word, obrc:word, obyx:word
	mov	ax,dlrc
	mov	dx,obrc
	cmp	dh,ah
	ja	rcinside_04
	cmp	dl,al
	ja	rcinside_04
	add	ax,dlyx
	add	dx,obyx
	cmp	ah,dh
	jb	rcinside_00	; below
	cmp	al,dl
	jb	rcinside_03	; left
	mov	ax,dlyx
	mov	dx,obyx
	cmp	ah,dh
	ja	rcinside_01	; above
	cmp	al,dl
	ja	rcinside_02	; right
	xor	ax,ax
	jmp	rcinside_05
    rcinside_00:
	mov	ax,1
	jmp	rcinside_05
    rcinside_01:
	mov	ax,2
	jmp	rcinside_05
    rcinside_02:
	mov	ax,3
	jmp	rcinside_05
    rcinside_03:
	mov	ax,4
	jmp	rcinside_05
    rcinside_04:
	mov	ax,5
    rcinside_05:
	ret
PEND	rcinside

	END
