		.386p
		ASSUME	CS:CODE,DS:DATA
		PUBLIC	AL_Write_Mountain_Flying
		PUBLIC	AL_Write_Building_Flying

HEAD_STR		EQU	48

STB_CODE		EQU	0
STB_POSI_POSI		EQU	4
STB_POSI_LAX		EQU	4
STB_POSI_LAX_UNIT	EQU	4
STB_POSI_LAX_OX		EQU	8
STB_POSI_LAX_OY		EQU	12
STB_POSI_LAX_OZ		EQU	16
STB_POSI_LAX_WDIR	EQU	20
STB_POSI_LAX_WDSIN	EQU	24
STB_DAT			EQU	32
STB_Z			EQU	36
STB_FLYING		EQU	40
STB_PREV		EQU	44
STB_NEXT		EQU	48

SAT_CX			EQU	0
SAT_CY			EQU	4
SAT_MG			EQU	8
SAT_CPZ			EQU	12
SAT_LX			EQU	16
SAT_LY			EQU	20


PRJ_CX		EQU	AL_prj
PRJ_CY		EQU	AL_prj+4
PRJ_MAG		EQU	AL_prj+8
PRJ_CPZ		EQU	AL_prj+12
PRJ_LX		EQU	AL_prj+16
PRJ_LY		EQU	AL_prj+20


STRP		MACRO	X
		MOV	[X  ],EAX
		MOV	[X+4],EBX
		MOV	[X+8],ECX
		ENDM

QROLLF		MACRO	DR
		PUSH	EAX
		PUSH	EBX
		IMUL	DWORD PTR [DR+4]
		XCHG	EBX,EAX
		MOV	ECX,EDX
		IMUL	DWORD PTR [DR]
		SUB	EBX,EAX
		SBB	ECX,EDX
		SHLD	ECX,EBX,16
		POP	EBX
		POP	EAX

		PUSH	ECX
		IMUL	DWORD PTR [DR]
		XCHG	EBX,EAX
		MOV	ECX,EDX
		IMUL	DWORD PTR [DR+4]
		ADD	EBX,EAX
		ADC	ECX,EDX
		SHRD	EBX,ECX,16
		POP	EAX
		ENDM


MAKETRI2D	MACRO	DST,SRC,P1,P2,P3
		LEA	EDI,[DST]
		LEA	EAX,[SRC]

		MOV	[EDI],DWORD PTR 3
		ADD	EDI,4

		LEA	ESI,[EAX+P1*8]
		MOVSD
		MOVSD
		LEA	ESI,[EAX+P2*8]
		MOVSD
		MOVSD
		LEA	ESI,[EAX+P3*8]
		MOVSD
		MOVSD
		ENDM

MAKEQUAD2D	MACRO	DST,SRC,P1,P2,P3,P4
		LEA	EDI,[DST]
		LEA	EAX,[SRC]

		MOV	[EDI],DWORD PTR 4
		ADD	EDI,4

		LEA	ESI,[EAX+P1*8]
		MOVSD
		MOVSD
		LEA	ESI,[EAX+P2*8]
		MOVSD
		MOVSD
		LEA	ESI,[EAX+P3*8]
		MOVSD
		MOVSD
		LEA	ESI,[EAX+P4*8]
		MOVSD
		MOVSD
		ENDM

INNERSGN	MACRO	V1,V2
		MOV	EAX,[V1]
		MOV	EDX,[V2]
		IMUL	EDX
		MOV	EBX,EAX
		MOV	ECX,EDX

		MOV	EAX,[V1+4]
		MOV	EDX,[V2+4]
		IMUL	EDX
		ADD	EBX,EAX
		ADC	ECX,EDX

		MOV	EAX,[V1+8]
		MOV	EDX,[V2+8]
		IMUL	EDX
		ADD	EBX,EAX
		ADC	ECX,EDX
		ENDM


CODE		SEGMENT
EXTRN		FxSinHq:NEAR, FxCosHq:NEAR
EXTRN		RotGtoVFast:NEAR
EXTRN		Projection:NEAR
EXTRN		YGH_color:NEAR,YGH_triangleArea:NEAR,YGH_polygonArea:NEAR
EXTRN		YGH_areaPaint:NEAR

;void AL_3D_WriteBuf_Mountain
;     (PAGE *dp,STRBUF *s,int *sit,SCRNATTR *atr)

AL_Write_Mountain_Flying	PROC
#SIT		EQU	EBP+16
#STRBUF		EQU	EBP+12
#PAGE		EQU	EBP+8
#RETADR		EQU	EBP+4
#EBP		EQU	EBP
#P		EQU	EBP-128
#PL1		EQU	EBP-256
#PL2		EQU	EBP-384
#DAT		EQU	EBP-388
#LDR		EQU	EBP-396
#WDR		EQU	EBP-404
#CX		EQU	EBP-408
#CZ		EQU	EBP-412
#ESPOFS		EQU	412
;    int p[32],pl1[32],pl2[32],*dat,ldr[2],*wdr;
;    int lx,lz,cx,cy,cz;

		PUSH	EBP
		MOV	EBP,ESP
		SUB	ESP,#ESPOFS
		PUSH	ESI
		PUSH	EDI
		PUSH	EBX

		CLD

;    dat=(*s).dat;
		MOV	ESI,[#STRBUF]
		MOV	EBX,[ESI+STB_DAT]
		MOV	[#DAT],EBX

;    ldr[0]=fxsinhq(dat[8]+(*s).posi.lax.wdir);
;    ldr[1]=fxcoshq(dat[8]+(*s).posi.lax.wdir);
		MOV	EBX,[EBX+32]
		ADD	EBX,[ESI+STB_POSI_LAX_WDIR]
		PUSH	EBX
		CALL	FxSinHq
		MOV	[#LDR],EAX
		PUSH	EBX
		CALL	FxCosHq
		MOV	[#LDR+4],EAX
		ADD	ESP,8

;    wdr=(*s).posi.lax.wdr;
		MOV	EAX,[ESI+ STB_POSI_LAX_WDSIN]
		MOV	[#WDR  ],EAX
		MOV	EAX,[ESI+ STB_POSI_LAX_WDSIN+4]
		MOV	[#WDR+4],EAX

;    cx=dat[5];
;    cz=dat[7];
;    rollFast(&cx,&cz,wdr);
;    cx+=(*s).posi.lax.ox;
;    cy =(*s).posi.lax.oy;
;    cz+=(*s).posi.lax.oz;
		MOV	EBX,[#DAT]
		MOV	EAX,[EBX+20]
		MOV	EBX,[EBX+28]
		QROLLF	#WDR
		ADD	EAX,[ESI+ STB_POSI_LAX_OX]
		ADD	EBX,[ESI+ STB_POSI_LAX_OZ]
		MOV	[#CX],EAX
		MOV	[#CZ],EBX


;    lx=dat[HEAD_STR+4];
;    lz=dat[HEAD_STR+5];
;    cy =(*s).posi.lax.oy;
;    p[ 0]= lx;    p[ 1] =cy;    p[ 2]= lz;  rollFast(p+ 0,p+ 2,ldr);
;    p[ 0]+=cx; p[ 2]+=cz;
;    p[ 3]= lx;    p[ 4] =cy;    p[ 5]=-lz;  rollFast(p+ 3,p+ 5,ldr);
;    p[ 3]+=cx; p[ 5]+=cz;
;    p[ 6]=-lx;    p[ 7] =cy;    p[ 8]=-lz;  rollFast(p+ 6,p+ 8,ldr);
;    p[ 6]+=cx; p[ 8]+=cz;
;    p[ 9]=-lx;    p[10] =cy;    p[11]= lz;  rollFast(p+ 9,p+11,ldr);
;    p[ 9]+=cx; p[11]+=cz;
;    p[12]=-lx+lz; p[13] =cy+lz; p[14] =0;   rollFast(p+12,p+14,ldr);
;    p[12]+=cx; p[14]+=cz;
;    p[15]= lx-lz; p[16] =cy+lz; p[17] =0;   rollFast(p+15,p+17,ldr);
;    p[15]+=cx; p[17]+=cz;
		LEA	EDI,[#P]
		MOV	ESI,[#DAT]

		MOV	EBX,[#STRBUF]
		MOV	EBX,[EBX+STB_POSI_LAX_OY]
		MOV	[EDI+ 4],EBX
		MOV	[EDI+16],EBX
		MOV	[EDI+28],EBX
		MOV	[EDI+40],EBX
		ADD	EBX,[ESI+HEAD_STR+20]
		MOV	[EDI+52],EBX
		MOV	[EDI+64],EBX

		MOV	EAX,[ESI+HEAD_STR+16]
		MOV	EBX,[ESI+HEAD_STR+20]
		QROLLF	#LDR
		PUSH	EAX
		PUSH	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI   ],EAX
		MOV	[EDI+ 8],EBX
		POP	EBX
		POP	EAX

		NEG	EAX
		NEG	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI+24],EAX
		MOV	[EDI+32],EBX


		MOV	EAX,[ESI+HEAD_STR+16]
		MOV	EBX,[ESI+HEAD_STR+20]
		NEG	EBX
		QROLLF	#LDR
		PUSH	EAX
		PUSH	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI+12],EAX
		MOV	[EDI+20],EBX
		POP	EBX
		POP	EAX

		NEG	EAX
		NEG	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI+36],EAX
		MOV	[EDI+44],EBX


		MOV	EAX,[ESI+HEAD_STR+20]
		SUB	EAX,[ESI+HEAD_STR+16]
		SUB	EBX,EBX
		QROLLF	#LDR
		PUSH	EAX
		PUSH	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI+48],EAX
		MOV	[EDI+56],EBX
		POP	EBX
		POP	EAX

		NEG	EAX
		NEG	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI+60],EAX
		MOV	[EDI+68],EBX


;    p[18]= 256; p[19]= 256; p[20]= 0;
;    rollFast(p+18,p+20,ldr);
;    p[21]=-256; p[22]= 256; p[23]= 0;
;    rollFast(p+21,p+23,ldr);
;    p[24]=   0; p[25]= 256; p[26]= 256;
;    rollFast(p+24,p+26,ldr);
;    p[27]=   0; p[28]= 256; p[29]=-256;
;    rollFast(p+27,p+29,ldr);
		LEA	EDI,[#P]
		MOV	EAX,256
		MOV	EBX,0
		QROLLF	#LDR
		MOV	[EDI+72],EAX
		MOV	[EDI+76],DWORD PTR 256
		MOV	[EDI+80],EBX

		NEG	EAX
		NEG	EBX
		MOV	[EDI+84],EAX
		MOV	[EDI+88],DWORD PTR  256
		MOV	[EDI+92],EBX

		MOV	EAX,0
		MOV	EBX,256
		QROLLF	#LDR
		MOV	[EDI+96], EAX
		MOV	[EDI+100],DWORD PTR 256
		MOV	[EDI+104],EBX

		NEG	EAX
		NEG	EBX
		MOV	[EDI+108],EAX
		MOV	[EDI+112],DWORD PTR 256
		MOV	[EDI+116],EBX

;    rollGtoVFast(10,p,p,sit);
;    Projection(6,pl1,p,(*atr).cx,(*atr).cy,(*atr).mg);
		PUSH	DWORD PTR [#SIT]
		PUSH	EDI
		PUSH	EDI
		PUSH	DWORD PTR 10
		CALL	RotGtoVFast
		ADD	ESP,16

		PUSH	DWORD PTR OFFSET AL_prj
		LEA	EAX,[#P]
		PUSH	EAX
		LEA	EAX,[#PL1]
		PUSH	EAX
		PUSH	DWORD PTR 6
		CALL	Projection
		ADD	ESP,16

;    if(innerSgn(p+18,p+15)<0)
;    {
;        YGH_color(dp,dat[HEAD_STR+0]);
;        makeTri2D(pl2,pl1,0,1,5);
;        if(!YGH_triangleArea(dp,AL_area,AL_ed,pl2))
;            YGH_areaPaint(dp,AL_area,AL_ed);
;    }
		INNERSGN	#P+72,#P+60
		JGE	#SQ1
		MAKETRI2D	#PL2,#PL1,0,1,5
		LEA	EBX,[#PL2]
		PUSH	EBX
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_triangleArea
		ADD	ESP,16
		AND	EAX,EAX
		JNE	#SQ1

		MOV	EAX,[#DAT]
		PUSH	DWORD PTR [EAX+HEAD_STR]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_color
		ADD	ESP,8

		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_areaPaint
		ADD	ESP,12

;    if(innerSgn(p+21,p+12)<0)
;    {
;        YGH_color(dp,dat[HEAD_STR+1]);
;        makeTri2D(pl2,pl1,2,3,4);
;        if(!YGH_triangleArea(dp,AL_area,AL_ed,pl2))
;            YGH_areaPaint(dp,AL_area,AL_ed);
;    }
#SQ1:		INNERSGN	#P+84,#P+48
		JGE	#SQ2
		MAKETRI2D	#PL2,#PL1,2,3,4
		LEA	EBX,[#PL2]
		PUSH	EBX
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_triangleArea
		ADD	ESP,16
		AND	EAX,EAX
		JNE	#SQ2

		MOV	EAX,[#DAT]
		PUSH	DWORD PTR [EAX+HEAD_STR+4]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_color
		ADD	ESP,8

		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_areaPaint
		ADD	ESP,12

;    if(innerSgn(p+24,p+15)<0)
;    {
;        YGH_color(dp,dat[HEAD_STR+2]);
;        makeQuad2D(pl2,pl1,0,3,4,5);
;        if(!YGH_triangleArea(dp,AL_area,AL_ed,pl2))
;            YGH_areaPaint(dp,AL_area,AL_ed);
;    }
#SQ2:		INNERSGN	#P+96,#P+60
		JGE	#SQ3
		MAKEQUAD2D	#PL2,#PL1,0,3,4,5
		LEA	EBX,[#PL2]
		PUSH	EBX
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_triangleArea
		ADD	ESP,16
		AND	EAX,EAX
		JNE	#SQ3

		MOV	EAX,[#DAT]
		PUSH	DWORD PTR [EAX+HEAD_STR+8]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_color
		ADD	ESP,8

		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_areaPaint
		ADD	ESP,12


;    if(innerSgn(p+27,p+15)<0)
;    {
;        YGH_color(dp,dat[HEAD_STR+3]);
;        makeQuad2D(pl2,pl1,1,2,4,5);
;        if(!YGH_triangleArea(dp,AL_area,AL_ed,pl2))
;            YGH_areaPaint(dp,AL_area,AL_ed);
;    }
#SQ3:		INNERSGN	#P+108,#P+60
		JGE	#EXIT
		MAKEQUAD2D	#PL2,#PL1,1,2,4,5
		LEA	EBX,[#PL2]
		PUSH	EBX
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_triangleArea
		ADD	ESP,16
		AND	EAX,EAX
		JNE	#EXIT

		MOV	EAX,[#DAT]
		PUSH	DWORD PTR [EAX+HEAD_STR+12]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_color
		ADD	ESP,8

		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_areaPaint
		ADD	ESP,12
;}

#EXIT:		POP	EBX
		POP	EDI
		POP	ESI
		MOV	ESP,EBP
		POP	EBP
		RET
AL_Write_Mountain_Flying	ENDP


;void AL_Write_Building_Flying
;     (PAGE *dp,STRBUF *s,int *sit,SCRNATTR *atr)
;{
AL_Write_Building_Flying	PROC
#SIT		EQU	EBP+16
#STRBUF		EQU	EBP+12
#PAGE		EQU	EBP+8
#RETADR		EQU	EBP+4
#EBP		EQU	EBP
#P		EQU	EBP-196
#PL1		EQU	EBP-392
#PL2		EQU	EBP-588
#DAT		EQU	EBP-592
#LDR		EQU	EBP-600
#WDR		EQU	EBP-608
#CX		EQU	EBP-612
#CZ		EQU	EBP-616
#ESPOFS		EQU	616
;    int p[48],pl1[48],pl2[32],*dat,ldr[2],*wdr;
;    int lx,lz,hi,cx,cy,cz;

		PUSH	EBP
		MOV	EBP,ESP
		SUB	ESP,#ESPOFS
		PUSH	ESI
		PUSH	EDI
		PUSH	EBX

		CLD

;    dat=(*s).dat;
		MOV	ESI,[#STRBUF]
		MOV	EBX,[ESI+STB_DAT]
		MOV	[#DAT],EBX

;    ldr[0]=fxsinhq(dat[8]);
;    ldr[1]=fxcoshq(dat[8]);
		MOV	EBX,[EBX+32]
		ADD	EBX,[ESI+STB_POSI_LAX_WDIR]
		PUSH	EBX
		CALL	FxSinHq
		MOV	[#LDR],EAX
		PUSH	EBX
		CALL	FxCosHq
		MOV	[#LDR+4],EAX
		ADD	ESP,8

;    wdr=(*s).posi.lax.wdr;
		MOV	EAX,[ESI+ STB_POSI_LAX_WDSIN  ]
		MOV	[#WDR  ],EAX
		MOV	EAX,[ESI+ STB_POSI_LAX_WDSIN+4]
		MOV	[#WDR+4],EAX

;    cx=dat[5];
;    cz=dat[7];
;    rollFast(&cx,&cz,wdr);
;    cx+=(*s).posi.lax.ox;
;    cy =(*s).posi.lax.oy;
;    cz+=(*s).posi.lax.oz;
		MOV	EBX,[#DAT]
		MOV	EAX,[EBX+20]
		MOV	EBX,[EBX+28]
		QROLLF	#WDR
		ADD	EAX,[ESI+ STB_POSI_LAX_OX]
		ADD	EBX,[ESI+ STB_POSI_LAX_OZ]
		MOV	[#CX],EAX
		MOV	[#CZ],EBX

;    lx=dat[HEAD_STR+5];
;    lz=dat[HEAD_STR+6];
;    p[ 0]= lx; p[ 1] =cy   ; p[ 2]= lz;  rollFast(p+ 0,p+ 2,ldr);
;    p[ 0]+=cx; p[ 2]+=cz;
;    p[ 3]= lx; p[ 4] =cy   ; p[ 5]=-lz;  rollFast(p+ 3,p+ 5,ldr);
;    p[ 3]+=cx; p[ 5]+=cz;
;    p[ 6]=-lx; p[ 7] =cy   ; p[ 8]=-lz;  rollFast(p+ 6,p+ 8,ldr);
;    p[ 6]+=cx; p[ 8]+=cz;
;    p[ 9]=-lx; p[10] =cy   ; p[11]= lz;  rollFast(p+ 9,p+11,ldr);
;    p[ 9]+=cx; p[11]+=cz;
		LEA	EDI,[#P]
		MOV	EBX,[ESI+ STB_POSI_LAX_OY]
		MOV	[EDI+ 4],EBX
		MOV	[EDI+16],EBX
		MOV	[EDI+28],EBX
		MOV	[EDI+40],EBX

		MOV	ESI,[#DAT]
		MOV	EAX,[ESI+HEAD_STR+20]
		MOV	EBX,[ESI+HEAD_STR+24]
		QROLLF	#LDR
		PUSH	EAX
		PUSH	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI  ],EAX
		MOV	[EDI+8],EBX
		POP	EBX
		POP	EAX

		NEG	EAX
		NEG	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI+24],EAX
		MOV	[EDI+32],EBX

		MOV	EAX,[ESI+HEAD_STR+20]
		MOV	EBX,[ESI+HEAD_STR+24]
		NEG	EBX
		QROLLF	#LDR
		PUSH	EAX
		PUSH	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI+12],EAX
		MOV	[EDI+20],EBX
		POP	EBX
		POP	EAX

		NEG	EAX
		NEG	EBX
		ADD	EAX,[#CX]
		ADD	EBX,[#CZ]
		MOV	[EDI+36],EAX
		MOV	[EDI+44],EBX

;    hi=dat[HEAD_STR+7];
;    p[12]=p[ 0]; p[13] =cy+hi; p[14]=p[ 2];
;    p[15]=p[ 3]; p[16] =cy+hi; p[17]=p[ 5];
;    p[18]=p[ 6]; p[19] =cy+hi; p[20]=p[ 8];
;    p[21]=p[ 9]; p[22] =cy+hi; p[23]=p[11];
		LEA	ESI,[#P]
		LEA	EDI,[#P+48]
		MOV	ECX,3*4
		REP	MOVSD
		MOV	EAX,[#DAT]
		MOV	EAX,[EAX+HEAD_STR+28]
		ADD	[#P+52],EAX
		ADD	[#P+64],EAX
		ADD	[#P+76],EAX
		ADD	[#P+88],EAX
		
;    p[24]= 256; p[25]=   0; p[26]=   0;
;    rollFast(p+24,p+26,ldr);
;    p[30]=-256; p[31]=   0; p[32]=   0;
;    rollFast(p+30,p+32,ldr);
		MOV	EAX,256
		MOV	EBX,0
		QROLLF	#LDR
		MOV	[#P+96] ,EAX
		MOV	[#P+100],DWORD PTR 0
		MOV	[#P+104],EBX

		NEG	EAX
		NEG	EBX
		MOV	[#P+120],EAX
		MOV	[#P+124],DWORD PTR 0
		MOV	[#P+128],EBX

;    p[27]=   0; p[28]=   0; p[29]=-256;
;    rollFast(p+27,p+29,ldr);
;    p[33]=   0; p[34]=   0; p[35]= 256;
;    rollFast(p+33,p+35,ldr);
		MOV	EAX,0
		MOV	EBX,-256
		QROLLF	#LDR
		MOV	[#P+108],EAX
		MOV	[#P+112],DWORD PTR 0
		MOV	[#P+116],EBX

		NEG	EAX
		NEG	EBX
		MOV	[#P+132],EAX
		MOV	[#P+136],DWORD PTR 0
		MOV	[#P+140],EBX

;    p[36]=   0; p[37]= 256; p[38]=   0;
		MOV	[#P+144],DWORD PTR 0
		MOV	[#P+148],DWORD PTR 256	;真上のベクトルに水平回転
		MOV	[#P+152],DWORD PTR 0	;は無意味だからやらない


;    rollGtoVFast(13,p,p,sit);
;    Projection(8,pl1,p,&AL_prj);
		PUSH	DWORD PTR [#SIT]
		LEA	EDI,[#P]
		PUSH	EDI
		PUSH	EDI
		PUSH	DWORD PTR 13
		CALL	RotGtoVFast
		ADD	ESP,16

		PUSH	DWORD PTR OFFSET AL_prj
		PUSH	EDI
		LEA	EAX,[#PL1]
		PUSH	EAX
		PUSH	DWORD PTR 8
		CALL	Projection
		ADD	ESP,16

;    if(innerSgn(p+24,p+ 0)<0)
;    {
;        makeQuad2D(pl2,pl1,0,1,5,4);
;        if(!YGH_triangleArea(dp,AL_area,AL_ed,pl2))
;        {
;            YGH_color(dp,dat[HEAD_STR+0]);
;            YGH_areaPaint(dp,AL_area,AL_ed);
;        }
;    }
		INNERSGN	#P+96,#P
		JGE	#SQ1
		MAKEQUAD2D	#PL2,#PL1,0,1,5,4
		LEA	EAX,[#PL2]
		PUSH	EAX
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_triangleArea
		ADD	ESP,16
		AND	EAX,EAX
		JNE	#SQ1
		MOV	EAX,[#DAT]
		PUSH	DWORD PTR [EAX+HEAD_STR]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_color
		ADD	ESP,8
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_areaPaint
		ADD	ESP,12
		
;    if(innerSgn(p+27,p+ 3)<0)
;    {
;        makeQuad2D(pl2,pl1,1,2,6,5);
;        if(!YGH_triangleArea(dp,AL_area,AL_ed,pl2))
;        {
;            YGH_color(dp,dat[HEAD_STR+1]);
;            YGH_areaPaint(dp,AL_area,AL_ed);
;        }
;    }
#SQ1:		INNERSGN	#P+108,#P+12
		JGE	#SQ2
		MAKEQUAD2D	#PL2,#PL1,1,2,6,5
		LEA	EAX,[#PL2]
		PUSH	EAX
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_triangleArea
		ADD	ESP,16
		AND	EAX,EAX
		JNE	#SQ2
		MOV	EAX,[#DAT]
		PUSH	DWORD PTR [EAX+HEAD_STR+4]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_color
		ADD	ESP,8
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_areaPaint
		ADD	ESP,12

;    if(innerSgn(p+30,p+ 6)<0)
;    {
;        makeQuad2D(pl2,pl1,2,3,7,6);
;        if(!YGH_triangleArea(dp,AL_area,AL_ed,pl2))
;        {
;            YGH_color(dp,dat[HEAD_STR+2]);
;            YGH_areaPaint(dp,AL_area,AL_ed);
;        }
;    }
#SQ2:		INNERSGN	#P+120,#P+24
		JGE	#SQ3
		MAKEQUAD2D	#PL2,#PL1,2,3,7,6
		LEA	EAX,[#PL2]
		PUSH	EAX
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_triangleArea
		ADD	ESP,16
		AND	EAX,EAX
		JNE	#SQ3
		MOV	EAX,[#DAT]
		PUSH	DWORD PTR [EAX+HEAD_STR+8]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_color
		ADD	ESP,8
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_areaPaint
		ADD	ESP,12


;    if(innerSgn(p+33,p+ 9)<0)
;    {
;        makeQuad2D(pl2,pl1,0,3,7,4);
;        if(!YGH_triangleArea(dp,AL_area,AL_ed,pl2))
;        {
;            YGH_color(dp,dat[HEAD_STR+3]);
;            YGH_areaPaint(dp,AL_area,AL_ed);
;        }
;    }
#SQ3:		INNERSGN	#P+132,#P+36
		JGE	#SQ4
		MAKEQUAD2D	#PL2,#PL1,0,3,7,4
		LEA	EAX,[#PL2]
		PUSH	EAX
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_triangleArea
		ADD	ESP,16
		AND	EAX,EAX
		JNE	#SQ4
		MOV	EAX,[#DAT]
		PUSH	DWORD PTR [EAX+HEAD_STR+12]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_color
		ADD	ESP,8
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_areaPaint
		ADD	ESP,12


;    if(innerSgn(p+36,p+12)<0)
;    {
;        makeQuad2D(pl2,pl1,4,5,6,7);
;        if(!YGH_triangleArea(dp,AL_area,AL_ed,pl2))
;        {
;            YGH_color(dp,dat[HEAD_STR+4]);
;            YGH_areaPaint(dp,AL_area,AL_ed);
;        }
;    }
;}
#SQ4:		INNERSGN	#P+144,#P+48
		JGE	#EXIT
		MAKEQUAD2D	#PL2,#PL1,4,5,6,7
		LEA	EAX,[#PL2]
		PUSH	EAX
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_triangleArea
		ADD	ESP,16
		AND	EAX,EAX
		JNE	#EXIT
		MOV	EAX,[#DAT]
		PUSH	DWORD PTR [EAX+HEAD_STR+16]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_color
		ADD	ESP,8
		PUSH	DWORD PTR OFFSET AL_ed
		PUSH	DWORD PTR [AL_area]
		PUSH	DWORD PTR [#PAGE]
		CALL	YGH_areaPaint
		ADD	ESP,12


#EXIT:		POP	EBX
		POP	EDI
		POP	ESI
		MOV	ESP,EBP
		POP	EBP
		RET
AL_Write_Building_Flying	ENDP

CODE		ENDS


DATA		SEGMENT
		EXTRN	AL_area:DWORD,AL_ed:DWORD
		EXTRN	AL_prj:DWORD
DATA		ENDS
		END
