		.386p
		ASSUME	CS:CODE
		INCLUDE YGHASM.H

		PUBLIC	YGH_circle,YGH_circleArea

ZERO		EQU	DWORD PTR 0

CODE		SEGMENT

YGH_circle	PROC
#R		EQU	EBP+20
#CY		EQU	EBP+16
#CX		EQU	EBP+12
#PAGE		EQU	EBP+8
#RETADR		EQU	EBP+4
#EBP		EQU	EBP

		PUSH	EBP
		MOV	EBP,ESP
		PUSH	ESI
		PUSH	EDI
		PUSH	EBX

		MOV	EDI,[#PAGE]
		MOV	EAX,[#CX]
		MOV	EBX,[#CY]
		MOV	ECX,[#R]

		LEA	EDX,[EAX+ECX]
		CMP	EDX,[EDI+YGH_VX2]
		JG	#NOTSAFE
		CMP	EDX,[EDI+YGH_VX1]
		JL	#EXIT

		LEA	EDX,[EBX+ECX]
		CMP	EDX,[EDI+YGH_VY2]
		JG	#NOTSAFE
		CMP	EDX,[EDI+YGH_VY1]
		JL	#EXIT

		MOV	EDX,EAX
		SUB	EDX,ECX
		CMP	EDX,[EDI+YGH_VX1]
		JL	#NOTSAFE
		CMP	EDX,[EDI+YGH_VX2]
		JG	#EXIT

		MOV	EDX,EBX
		SUB	EDX,ECX
		CMP	EDX,[EDI+YGH_VY1]
		JL	#NOTSAFE
		CMP	EDX,[EDI+YGH_VY2]
		JG	#EXIT


		CALL	FLYINGCIRCLEDRAW
		POP	EBX
		POP	EDI
		POP	ESI
		MOV	ESP,EBP
		POP	EBP
		MOV	EAX,0
		RET
		
		ALIGN	4
#NOTSAFE:	CALL	CIRCLEDRAW
#EXIT:		POP	EBX
		POP	EDI
		POP	ESI
		MOV	ESP,EBP
		POP	EBP
		MOV	EAX,0
		RET
YGH_circle	ENDP





CHECKV		MACRO	VIEWOUT
		CMP	EAX,[#VX1]
		JL	VIEWOUT
		CMP	EAX,[#VX2]
		JG	VIEWOUT
		CMP	EBX,[#VY1]
		JL	VIEWOUT
		CMP	EBX,[#VY2]
		JG	VIEWOUT
		ENDM



;CIRCLEDRAW
;EAX,EBX:cx,cy    ECX:R   EDI:PAGE
		ALIGN	4
CIRCLEDRAW	PROC
#ESPOFS		EQU	124
#VY2		EQU	ESP+120
#VX2		EQU	ESP+116
#VY1		EQU	ESP+112
#VX1		EQU	ESP+108
#Y		EQU	ESP+104
#X		EQU	ESP+100
#RF		EQU	ESP+96
#ADR8		EQU	ESP+92
#Y8		EQU	ESP+88
#X8		EQU	ESP+84
#ADR7		EQU	ESP+80
#Y7		EQU	ESP+76
#X7		EQU	ESP+72
#ADR6		EQU	ESP+68
#Y6		EQU	ESP+64
#X6		EQU	ESP+60
#ADR5		EQU	ESP+56
#Y5		EQU	ESP+52
#X5		EQU	ESP+48
#ADR4		EQU	ESP+44
#Y4		EQU	ESP+40
#X4		EQU	ESP+36
#ADR3		EQU	ESP+32
#Y3		EQU	ESP+28
#X3		EQU	ESP+24
#ADR2		EQU	ESP+20
#Y2		EQU	ESP+16
#X2		EQU	ESP+12
#ADR1		EQU	ESP+8
#Y1		EQU	ESP+4
#X1		EQU	ESP

		PUSH	DS
		PUSH	ES

		SUB	ESP,#ESPOFS
		PUSH	DS
		POP	ES
		MOV	EDX,[EDI+YGH_SEG]
		MOV	DS,DX

		MOV	[#X],ECX
		MOV	[#Y],DWORD PTR 0

		LEA	EDX,[EAX+ECX]
		MOV	[#X1],EDX
		MOV	[#Y1],EBX
		MOV	[#X4],EDX
		MOV	[#Y4],EBX
		MOV	ESI,EBX
		IMUL	ESI,ES:[EDI+YGH_ODW]
		ADD	ESI,ES:[EDI+YGH_ADR]
		LEA	ESI,[ESI+EDX*2]
		MOV	[#ADR1],ESI
		MOV	[#ADR4],ESI

		MOV	EDX,EAX
		SUB	EDX,ECX
		MOV	[#X2],EDX
		MOV	[#Y2],EBX
		MOV	[#X3],EDX
		MOV	[#Y3],EBX
		MOV	ESI,EBX
		IMUL	ESI,ES:[EDI+YGH_ODW]
		ADD	ESI,ES:[EDI+YGH_ADR]
		LEA	ESI,[ESI+EDX*2]
		MOV	[#ADR2],ESI
		MOV	[#ADR3],ESI

		MOV	EDX,EBX
		SUB	EDX,ECX
		MOV	[#X5],EAX
		MOV	[#Y5],EDX
		MOV	[#X6],EAX
		MOV	[#Y6],EDX
		IMUL	EDX,ES:[EDI+YGH_ODW]
		ADD	EDX,ES:[EDI+YGH_ADR]
		LEA	EDX,[EDX+EAX*2]
		MOV	[#ADR5],EDX
		MOV	[#ADR6],EDX

		LEA	EDX,[EBX+ECX]
		MOV	[#X7],EAX
		MOV	[#Y7],EDX
		MOV	[#X8],EAX
		MOV	[#Y8],EDX
		IMUL	EDX,ES:[EDI+YGH_ODW]
		ADD	EDX,ES:[EDI+YGH_ADR]
		LEA	EDX,[EDX+EAX*2]
		MOV	[#ADR7],EDX
		MOV	[#ADR8],EDX

		MOV	EDX,ES:[EDI+YGH_VX1]
		MOV	[#VX1],EDX
		MOV	EDX,ES:[EDI+YGH_VY1]
		MOV	[#VY1],EDX
		MOV	EDX,ES:[EDI+YGH_VX2]
		MOV	[#VX2],EDX
		MOV	EDX,ES:[EDI+YGH_VY2]
		MOV	[#VY2],EDX

		MOV	[#RF],ZERO
		MOV	EDX,ES:[EDI+YGH_COL]
		MOV	ESI,ES:[EDI+YGH_ODW]

		ALIGN	4
#LOOP1:		MOV	EAX,[#X1]
		MOV	EBX,[#Y1]
		CHECKV	#L1
		MOV	ECX,[#ADR1]
		MOV	[ECX],DX
#L1:
		MOV	EAX,[#X2]
		MOV	EBX,[#Y2]
		CHECKV	#L2
		MOV	ECX,[#ADR2]
		MOV	[ECX],DX
#L2:
		MOV	EAX,[#X3]
		MOV	EBX,[#Y3]
		CHECKV	#L3
		MOV	ECX,[#ADR3]
		MOV	[ECX],DX
#L3:
		MOV	EAX,[#X4]
		MOV	EBX,[#Y4]
		CHECKV	#L4
		MOV	ECX,[#ADR4]
		MOV	[ECX],DX
#L4:
		MOV	EAX,[#X5]
		MOV	EBX,[#Y5]
		CHECKV	#L5
		MOV	ECX,[#ADR5]
		MOV	[ECX],DX
#L5:
		MOV	EAX,[#X6]
		MOV	EBX,[#Y6]
		CHECKV	#L6
		MOV	ECX,[#ADR6]
		MOV	[ECX],DX
#L6:
		MOV	EAX,[#X7]
		MOV	EBX,[#Y7]
		CHECKV	#L7
		MOV	ECX,[#ADR7]
		MOV	[ECX],DX
#L7:
		MOV	EAX,[#X8]
		MOV	EBX,[#Y8]
		CHECKV	#L8
		MOV	ECX,[#ADR8]
		MOV	[ECX],DX
#L8:

		SUB	[#Y1],DWORD PTR 1
		SUB	[#ADR1],ESI
		SUB	[#Y2],DWORD PTR 1
		SUB	[#ADR2],ESI
		ADD	[#Y3],DWORD PTR 1
		ADD	[#ADR3],ESI
		ADD	[#Y4],DWORD PTR 1
		ADD	[#ADR4],ESI

		ADD	[#X5],DWORD PTR 1
		ADD	[#ADR5],DWORD PTR 2
		SUB	[#X6],DWORD PTR 1
		SUB	[#ADR6],DWORD PTR 2
		SUB	[#X7],DWORD PTR 1
		SUB	[#ADR7],DWORD PTR 2
		ADD	[#X8],DWORD PTR 1
		ADD	[#ADR8],DWORD PTR 2

		MOV	ECX,[#Y]
		INC	DWORD PTR [#Y]
		ADD	[#RF],ECX
		ADD	[#RF],ECX
		ADD	[#RF],DWORD PTR 1
		JLE	#LOOP1


		SUB	[#X1],DWORD PTR 1
		SUB	[#ADR1],DWORD PTR 2
		ADD	[#X2],DWORD PTR 1
		ADD	[#ADR2],DWORD PTR 2
		ADD	[#X3],DWORD PTR 1
		ADD	[#ADR3],DWORD PTR 2
		SUB	[#X4],DWORD PTR 1
		SUB	[#ADR4],DWORD PTR 2

		ADD	[#Y5],DWORD PTR 1
		ADD	[#ADR5],ESI
		ADD	[#Y6],DWORD PTR 1
		ADD	[#ADR6],ESI
		SUB	[#Y7],DWORD PTR 1
		SUB	[#ADR7],ESI
		SUB	[#Y8],DWORD PTR 1
		SUB	[#ADR8],ESI

		MOV	ECX,[#X]
		DEC	DWORD PTR [#X]
		SUB	[#RF],ECX
		SUB	[#RF],ECX
		ADD	[#RF],DWORD PTR 1
		MOV	ECX,[#Y]
		CMP	ECX,[#X]
		JLE	#LOOP1

		ADD	ESP,#ESPOFS
		POP	ES
		POP	DS
		RET
CIRCLEDRAW	ENDP




;CIRCLEDRAW
;EAX,EBX:cx,cy    ECX:R   EDI:PAGE
		ALIGN	4
FLYINGCIRCLEDRAW	PROC
#ESPOFS		EQU	44
#Y		EQU	ESP+40
#X		EQU	ESP+36
#RF		EQU	ESP+32
#ADR8		EQU	ESP+28
#ADR7		EQU	ESP+24
#ADR6		EQU	ESP+20
#ADR5		EQU	ESP+16
#ADR4		EQU	ESP+12
#ADR3		EQU	ESP+8
#ADR2		EQU	ESP+4
#ADR1		EQU	ESP

		PUSH	DS
		PUSH	ES
		PUSH	EBP

		SUB	ESP,#ESPOFS
		PUSH	DS
		POP	ES
		MOV	EDX,[EDI+YGH_SEG]
		MOV	DS,DX

		MOV	[#X],ECX
		MOV	[#Y],DWORD PTR 0

		LEA	EDX,[EAX+ECX]
		MOV	ESI,EBX
		IMUL	ESI,ES:[EDI+YGH_ODW]
		ADD	ESI,ES:[EDI+YGH_ADR]
		LEA	ESI,[ESI+EDX*2]
		MOV	[#ADR1],ESI
		MOV	[#ADR4],ESI

		MOV	EDX,EAX
		SUB	EDX,ECX
		MOV	ESI,EBX
		IMUL	ESI,ES:[EDI+YGH_ODW]
		ADD	ESI,ES:[EDI+YGH_ADR]
		LEA	ESI,[ESI+EDX*2]
		MOV	[#ADR2],ESI
		MOV	[#ADR3],ESI

		MOV	EDX,EBX
		SUB	EDX,ECX
		IMUL	EDX,ES:[EDI+YGH_ODW]
		ADD	EDX,ES:[EDI+YGH_ADR]
		LEA	EDX,[EDX+EAX*2]
		MOV	[#ADR5],EDX
		MOV	[#ADR6],EDX

		LEA	EDX,[EBX+ECX]
		IMUL	EDX,ES:[EDI+YGH_ODW]
		ADD	EDX,ES:[EDI+YGH_ADR]
		LEA	EDX,[EDX+EAX*2]
		MOV	[#ADR7],EDX
		MOV	[#ADR8],EDX


		MOV	[#RF],ZERO
		MOV	EBP,ES:[EDI+YGH_COL]
		MOV	ESI,ES:[EDI+YGH_ODW]
		MOV	EAX,[#ADR1]
		MOV	EBX,[#ADR2]
		MOV	ECX,[#ADR3]
		MOV	EDX,[#ADR4]


		ALIGN	4
#LOOP1:		MOV	[EAX],BP
		MOV	[EBX],BP
		MOV	[ECX],BP
		MOV	[EDX],BP

		MOV	EDI,[#ADR5]
		MOV	[EDI],BP
		MOV	EDI,[#ADR6]
		MOV	[EDI],BP
		MOV	EDI,[#ADR7]
		MOV	[EDI],BP
		MOV	EDI,[#ADR8]
		MOV	[EDI],BP


		SUB	EAX,ESI
		SUB	EBX,ESI
		ADD	ECX,ESI
		ADD	EDX,ESI

		ADD	[#ADR5],DWORD PTR 2
		SUB	[#ADR6],DWORD PTR 2
		SUB	[#ADR7],DWORD PTR 2
		ADD	[#ADR8],DWORD PTR 2

		MOV	EDI,[#Y]
		INC	DWORD PTR [#Y]
		ADD	[#RF],EDI
		ADD	[#RF],EDI
		ADD	[#RF],DWORD PTR 1
		JLE	#LOOP1


		SUB	EAX,2
		ADD	EBX,2
		ADD	ECX,2
		SUB	EDX,2

		ADD	[#ADR5],ESI
		ADD	[#ADR6],ESI
		SUB	[#ADR7],ESI
		SUB	[#ADR8],ESI

		MOV	EDI,[#X]
		DEC	DWORD PTR [#X]
		SUB	[#RF],EDI
		SUB	[#RF],EDI
		ADD	[#RF],DWORD PTR 1
		MOV	EDI,[#Y]
		CMP	EDI,[#X]
		JLE	#LOOP1

		ADD	ESP,#ESPOFS
		POP	EBP
		POP	ES
		POP	DS
		RET
FLYINGCIRCLEDRAW	ENDP







;int   YGH_circleArea(PAGE *p,int *plg,int *edg,int x,int y,int r);
		ALIGN	4
YGH_circleArea	PROC
#R		EQU	EBP+28
#Y		EQU	EBP+24
#X		EQU	EBP+20
#EDG		EQU	EBP+16
#PLG		EQU	EBP+12
#PAGE		EQU	EBP+8
#RETADR		EQU	EBP+4
#EBP		EQU	EBP
		PUSH	EBP
		MOV	EBP,ESP
		PUSH	ESI
		PUSH	EDI
		PUSH	EBX

		MOV	EDI,[#PAGE]
		MOV	ESI,[#EDG]

		MOV	EAX,[#X]
		SUB	EAX,[#R]
		MOV	[ESI   ],EAX
		MOV	EBX,[#Y]
		SUB	EBX,[#R]
		MOV	[ESI+ 4],EBX

		MOV	ECX,[#X]
		ADD	ECX,[#R]
		MOV	[ESI+8 ],ECX
		MOV	EDX,[#Y]
		ADD	EDX,[#R]
		MOV	[ESI+12],EDX

		CMP	EAX,[EDI+YGH_VX2]
		JG	#NOAREA
		CMP	ECX,[EDI+YGH_VX1]
		JL	#NOAREA
		CMP	EBX,[EDI+YGH_VY2]
		JG	#NOAREA
		CMP	EDX,[EDI+YGH_VY1]
		JL	#NOAREA

		CMP	EAX,[EDI+YGH_VX1]
		JL	#DANGER
		CMP	ECX,[EDI+YGH_VX2]
		JG	#DANGER
		CMP	EBX,[EDI+YGH_VY1]
		JL	#DANGER
		CMP	EDX,[EDI+YGH_VY2]
		JG	#DANGER

		MOV	EAX,[#X]
		MOV	EBX,[#Y]
		MOV	ECX,[#R]
		MOV	EDX,[#PLG]
		CALL	FLYINGCIRCLEAREA
		POP	EBX
		POP	EDI
		POP	ESI
		MOV	ESP,EBP
		POP	EBP
		MOV	EAX,0
		RET


#DANGER:	MOV	EAX,[#X]
		MOV	EBX,[#Y]
		MOV	ECX,[#R]
		MOV	EDX,[#PLG]
		CALL	CIRCLEAREA

		POP	EBX
		POP	EDI
		POP	ESI
		MOV	ESP,EBP
		POP	EBP
		MOV	EAX,0
		RET

#NOAREA:	POP	EBX
		POP	EDI
		POP	ESI
		MOV	ESP,EBP
		POP	EBP
		MOV	EAX,1
		RET
YGH_circleArea	ENDP



;void circleArea(int *plg,int cx,int cy,int r)
;{
;    int ro,rf,mx,my,x,y;
;    int *p1,*p2,*p3,*p4;
;
;    mnx=cx-r;
;    max=cx+r;
;    mny=cy-r;
;    may=cy+r;
;
;    ro=r*r;
;    rf=ro;
;    mx=r;
;    my=0;
;
;    p1=plg+cy*XBUF;
;    p2=plg+cy*XBUF;
;    p3=plg+(cy-r)*XBUF;
;    p4=plg+(cy+r)*XBUF;
;
;
;    if(vy1<=cy && cy<vy2)
;    {
;        p1[0]=2;
;        x=cx-r;
;        if(x<vx1)x=vx1;
;        p1[1]=x;
;        x=cx+r;
;        if(x>vx2)x=vx2;
;        p1[2]=x;
;    }
;
;    while(my<mx)
;    {
;        y=cy-mx;
;        if(vy1<=y && y<=vy2)
;        {
;            p3[0]=2;
;            x=cx-my;
;            if(x<vx1)x=vx1;
;            p3[1]=x;
;            x=cx+my;
;            if(x>vx2)x=vx2;
;            p3[2]=x;
;        }
;
;        y=cy+mx;
;        if(vy1<=y && y<=vy2)
;        {
;            p4[0]=2;
;            x=cx-my;
;            if(x<vx1)x=vx1;
;            p4[1]=x;
;            x=cx+my;
;            if(x>vx2)x=vx2;
;            p4[2]=x;
;        }
;
;        rf+=(1+my+my);
;        p1-=XBUF;
;        p2+=XBUF;
;        my++;
;
;        if(rf>=ro)
;        {
;            rf+=(1-mx-mx);
;            p3+=XBUF;
;            p4-=XBUF;
;            mx--;
;        }
;
;        y=cy-my;
;        if(vy1<=y && y<=vy2)
;        {
;            p1[0]=2;
;            x=cx-mx;
;            if(x<vx1)x=vx1;
;            p1[1]=x;
;            x=cx+mx;
;            if(x>vx2)x=vx2;
;            p1[2]=x;
;        }
;
;        y=cy+my;
;        if(vy1<=y && y<=vy2)
;        {
;            p2[0]=2;
;            x=cx-mx;
;            if(x<vx1)x=vx1;
;            p2[1]=x;
;            x=cx+mx;
;            if(x>vx2)x=vx2;
;            p2[2]=x;
;        }
;    }
;}


VX1CUT		MACRO	X
		LOCAL	EX
		CMP	X,[#VX1]
		JGE	EX
		MOV	X,[#VX1]
EX:
		ENDM

VX2CUT		MACRO	X
		LOCAL	EX
		CMP	X,[#VX2]
		JLE	EX
		MOV	X,[#VX2]
EX:
		ENDM


YBOUND		MACRO	Y,YOUT
		CMP	Y,[#VY1]
		JL	YOUT
		CMP	Y,[#VY2]
		JG	YOUT
		ENDM


;EDI:PAGE    EAX,EBX,ECX:CX,CY,R    EDX:AREA
		ALIGN	4
CIRCLEAREA	PROC

#ESPOFS		EQU	52
#RF		EQU	ESP+48
#CY		EQU	ESP+44
#CX		EQU	ESP+40
#MY		EQU	ESP+36
#MX		EQU	ESP+32
#P4		EQU	ESP+28
#P3		EQU	ESP+24
#P2		EQU	ESP+20
#P1		EQU	ESP+16
#VY2		EQU	ESP+12
#VX2		EQU	ESP+8
#VY1		EQU	ESP+4
#VX1		EQU	ESP

		PUSH	EBP
		SUB	ESP,#ESPOFS

		MOV	ESI,[EDI+YGH_VX1]
		MOV	[#VX1],ESI
		MOV	ESI,[EDI+YGH_VY1]
		MOV	[#VY1],ESI
		MOV	ESI,[EDI+YGH_VX2]
		MOV	[#VX2],ESI
		MOV	ESI,[EDI+YGH_VY2]
		MOV	[#VY2],ESI		;EDI‰ð•ú

		MOV	[#CX],EAX
		MOV	[#CY],EBX
		MOV	[#MX],ECX
		MOV	[#MY],DWORD PTR 0

		MOV	ESI,EBX
		SHL	ESI,YGH_XBUFSHIFT
		ADD	ESI,EDX
		MOV	[#P1],ESI

		MOV	ESI,EBX
		SHL	ESI,YGH_XBUFSHIFT
		ADD	ESI,EDX
		MOV	[#P2],ESI

		MOV	ESI,EBX
		SUB	ESI,ECX
		SHL	ESI,YGH_XBUFSHIFT
		ADD	ESI,EDX
		MOV	[#P3],ESI

		LEA	ESI,[EBX+ECX]
		SHL	ESI,YGH_XBUFSHIFT
		ADD	ESI,EDX
		MOV	[#P4],ESI		;EDX‰ð•ú

		YBOUND	EBX,#CYisOUT
		MOV	ESI,[#P1]
		MOV	[ESI],DWORD PTR 2
		MOV	EDX,EAX
		SUB	EDX,ECX
		VX1CUT	EDX
		MOV	[ESI+4],EDX
		LEA	EDX,[EAX+ECX]
		VX2CUT	EDX
		MOV	[ESI+8],EDX

#CYisOUT:	AND	ECX,ECX
		JE	#EXIT

		MOV	EAX,[#CX]
		MOV	EBX,[#CY]
		MOV	ECX,[#MX]
		MOV	EDX,[#MY]
		MOV	[#RF],DWORD PTR 0

#LOOP0:
		MOV	ESI,EAX
		SUB	ESI,EDX
		VX1CUT	ESI
		LEA	EBP,[EAX+EDX]
		VX2CUT	EBP

		MOV	EDI,EBX
		SUB	EDI,ECX
		YBOUND	EDI,#L1
		MOV	EDI,[#P3]
		MOV	[EDI],DWORD PTR 2
		MOV	[EDI+4],ESI
		MOV	[EDI+8],EBP
#L1:
		LEA	EDI,[EBX+ECX]
		YBOUND	EDI,#L2
		MOV	EDI,[#P4]
		MOV	[EDI],DWORD PTR 2
		MOV	[EDI+4],ESI
		MOV	[EDI+8],EBP
#L2:


		SUB	[#P1],DWORD PTR YGH_XBUF*4
		ADD	[#P2],DWORD PTR YGH_XBUF*4
		ADD	[#RF],EDX
		ADD	[#RF],EDX
		INC	EDX
		ADD	[#RF],DWORD PTR 1
		JL	#L2DASH

		ADD	[#P3],DWORD PTR YGH_XBUF*4
		SUB	[#P4],DWORD PTR YGH_XBUF*4
		SUB	[#RF],ECX
		SUB	[#RF],ECX
		DEC	ECX
		ADD	[#RF],DWORD PTR 1
#L2DASH:
		MOV	ESI,EAX
		SUB	ESI,ECX
		VX1CUT	ESI
		LEA	EBP,[EAX+ECX]
		VX2CUT	EBP

		MOV	EDI,EBX
		SUB	EDI,EDX
		YBOUND	EDI,#L3
		MOV	EDI,[#P1]
		MOV	[EDI],DWORD PTR 2
		MOV	[EDI+4],ESI
		MOV	[EDI+8],EBP
#L3:
		LEA	EDI,[EBX+EDX]
		YBOUND	EDI,#L4
		MOV	EDI,[#P2]
		MOV	[EDI],DWORD PTR 2
		MOV	[EDI+4],ESI
		MOV	[EDI+8],EBP
#L4:
		CMP	EDX,ECX
		JL	#LOOP0


#EXIT:		ADD	ESP,#ESPOFS
		POP	EBP
		RET
CIRCLEAREA	ENDP


		ALIGN	4
FLYINGCIRCLEAREA	PROC

#ESPOFS		EQU	48
#CY		EQU	ESP+44
#CX		EQU	ESP+40
#MY		EQU	ESP+36
#MX		EQU	ESP+32
#P4		EQU	ESP+28
#P3		EQU	ESP+24
#P2		EQU	ESP+20
#P1		EQU	ESP+16
#VY2		EQU	ESP+12
#VX2		EQU	ESP+8
#VY1		EQU	ESP+4
#VX1		EQU	ESP

		PUSH	EBP
		SUB	ESP,#ESPOFS

		MOV	ESI,[EDI+YGH_VX1]
		MOV	[#VX1],ESI
		MOV	ESI,[EDI+YGH_VY1]
		MOV	[#VY1],ESI
		MOV	ESI,[EDI+YGH_VX2]
		MOV	[#VX2],ESI
		MOV	ESI,[EDI+YGH_VY2]
		MOV	[#VY2],ESI		;EDI‰ð•ú

		MOV	[#CX],EAX
		MOV	[#CY],EBX
		MOV	[#MX],ECX
		MOV	[#MY],DWORD PTR 0

		MOV	ESI,EBX
		SHL	ESI,YGH_XBUFSHIFT
		ADD	ESI,EDX
		MOV	[#P1],ESI

		MOV	ESI,EBX
		SHL	ESI,YGH_XBUFSHIFT
		ADD	ESI,EDX
		MOV	[#P2],ESI

		MOV	ESI,EBX
		SUB	ESI,ECX
		SHL	ESI,YGH_XBUFSHIFT
		ADD	ESI,EDX
		MOV	[#P3],ESI

		LEA	ESI,[EBX+ECX]
		SHL	ESI,YGH_XBUFSHIFT
		ADD	ESI,EDX
		MOV	[#P4],ESI		;EDX‰ð•ú

		MOV	ESI,[#P1]
		MOV	[ESI],DWORD PTR 2
		MOV	EDX,EAX
		SUB	EDX,ECX
		MOV	[ESI+4],EDX
		LEA	EDX,[EAX+ECX]
		MOV	[ESI+8],EDX

		AND	ECX,ECX
		JE	#EXIT

		MOV	EAX,[#CX]
		MOV	ECX,[#MX]
		MOV	EDX,[#MY]
		MOV	EBP,0                   ;EBP:RF

#LOOP0:		MOV	EDI,[#P3]
		MOV	EBX,[#P4]
		MOV	[EDI],DWORD PTR 2
		MOV	[EBX],DWORD PTR 2
		MOV	ESI,EAX
		SUB	ESI,EDX
		MOV	[EDI+4],ESI
		MOV	[EBX+4],ESI
		LEA	ESI,[EAX+EDX]
		MOV	[EDI+8],ESI
		MOV	[EBX+8],ESI

		SUB	[#P1],DWORD PTR YGH_XBUF*4
		ADD	[#P2],DWORD PTR YGH_XBUF*4
		LEA	EBP,[EBP+EDX*2]
		INC	EDX
		ADD	EBP,1
		JL	#L2DASH

		ADD	[#P3],DWORD PTR YGH_XBUF*4
		SUB	[#P4],DWORD PTR YGH_XBUF*4
		SUB	EBP,ECX
		SUB	EBP,ECX
		DEC	ECX
		ADD	EBP,DWORD PTR 1
#L2DASH:

		MOV	EDI,[#P1]
		MOV	EBX,[#P2]
		MOV	[EDI],DWORD PTR 2
		MOV	[EBX],DWORD PTR 2
		MOV	ESI,EAX
		SUB	ESI,ECX
		MOV	[EDI+4],ESI
		MOV	[EBX+4],ESI
		LEA	ESI,[EAX+ECX]
		MOV	[EDI+8],ESI
		MOV	[EBX+8],ESI

		CMP	EDX,ECX
		JL	#LOOP0


#EXIT:		ADD	ESP,#ESPOFS
		POP	EBP
		RET
FLYINGCIRCLEAREA	ENDP


CODE		ENDS
		END
