; Graphics Vision Visibility Detection / Drawing Support
; Copr. 1994 Matthias K”ppe
; Gvisible

		INCLUDE	grdef.asm

maxRect		EQU	16

TVRECT		STRUC
  Count		DW	?
  Next		DD	?
  R		TRECT	maxRect DUP (?)
TVRECT		ENDS

CODE		SEGMENT BYTE PUBLIC

		PUBLIC	ForEachRect

ForEachRect	PROC NEAR
		ARG	Action: DWORD, List: DWORD = ArgSize
		push	bp
		mov	bp, sp
		les	di, List
@@2:		mov	ax, es
		or	ax, di
		jz	@@0
		mov	cx, es:[di].TVRect.Count
		push	WORD PTR es:[di].TVRect.Next[2]
		push	WORD PTR es:[di].TVRect.Next[0]
		or	cx, cx
		jz	@@4
		add	di, TVRect.R
@@1:
		mov     ax, es:[di].TRect.A.X
		cmp     ax, es:[di].TRect.B.X
		jge     @@3			; empty
		mov     ax, es:[di].TRect.A.Y
		cmp     ax, es:[di].TRect.B.Y
		jge     @@3			; empty
		push	cx es di
		push	es di
		push	WORD PTR [bp]
		call	WORD PTR Action
		pop	di es cx
@@3:		add	di, 8
		loop	@@1
@@4:		pop	di es
		jmp	@@2
@@0:		pop	bp
		retn	ArgSize
ForEachRect	ENDP

CODE		ENDS

		END


