;	»CuEOtBbNΡ
;	(c) MATSUUCHI Ryosuke in Dec,1992
;
;	gboxfill.asm
;
;	1992. 7.16(Thu)
;	1992.12.28(Sun)


		public	gboxfill,grboxfill,_gboxfill,_grboxfill
		extrn	_gwrtreg:near, _ghline:near
		
		include	grplib.inc
		
		assume	cs:cseg, ds:dseg



dseg segment dword 'DATA'
dseg ends



cseg segment dword 'CODE'

;---------------------------------------------------------------
;	_gboxfill : 
;		in  eax:x1
;		    ebx:y1
;		    ecx:x2
;		    edx:y2
;		    esi:col
;		    edi:logop
;
;	void gboxfill(int x1, int y1, int x2, int y2, int col, int logop);
;	void grboxfill(int x1, int y1, int xlen, int ylen, int col, int logop);
;---------------------------------------------------------------


gboxfill	proc
		push	ebx
		push	esi
		push	edi
		pushfd
		mov	eax,[esp+16+4]
		mov	ebx,[esp+16+8]
		mov	ecx,[esp+16+12]
		mov	edx,[esp+16+16]
		mov	esi,[esp+16+20]
		mov	edi,[esp+16+24]
		call	_gboxfill
		popfd
		pop	edi
		pop	esi
		pop	ebx
		ret
gboxfill	endp



grboxfill	proc
		push	ebx
		push	esi
		push	edi
		pushfd
		mov	eax,[esp+16+4]
		mov	ebx,[esp+16+8]
		mov	ecx,[esp+16+12]
		mov	edx,[esp+16+16]
		mov	esi,[esp+16+20]
		mov	edi,[esp+16+24]
		call	_grboxfill
		popfd
		pop	edi
		pop	esi
		pop	ebx
		ret
grboxfill	endp



_grboxfill	proc
		or	ecx,ecx
		jz	#end
		or	edx,edx
		jz	#end
		push	ecx
		push	edx
		lea	ecx,[eax+ecx-1]
		lea	edx,[ebx+edx-1]
		call	_gboxfill
		pop	edx
		pop	ecx
#end:		ret
_grboxfill	endp



_gboxfill	proc
		pushad
		xchg	ebx,ecx		;ebx © x2
		xchg	ecx,edx		;ecx © y2
		xchg	edx,esi		;edx © col
		xchg	esi,edi		;esi © logop, edi © y1
		cmp	ecx,edi		;ecx©min(y1,y2), edi©max(y1,y2)
		jl	#0
			xchg	ecx,edi
		#0:
		#loop:
			call	_ghline
			inc	ecx
			cmp	ecx,edi
		jle	#loop
		popad
		ret
_gboxfill	endp



cseg ends

end
