		.386p
		ASSUME	CS:CODE

		PUBLIC AL_Crash_Polygon_Linear


CLIP		MACRO	CPP
;Y=(X-X1)(Y2-Y1)/(X2-X1)+Y1
		SUB	EDX,EBX		;EDX=Y2-Y1
		SUB	ECX,EAX		;ECX=X2-X1
		SUB	EAX,CPP		;EAX=(X1-X)*-1
		NEG	EAX		;   = X-X1
		IMUL	EDX		;EAX:EDX=(X-X1)(Y2-Y1)
		IDIV	ECX		;EAX=(X-X1)(Y2-Y1)/(X2-X1)
		ADD	EAX,EBX		;EAX=(X-X1)(Y2-Y1)/(X2-X1)+Y1

		ENDM

CODE		SEGMENT

AL_Crash_Polygon_Linear	PROC
#X		EQU	ESP+24
#Y2		EQU	ESP+20
#X2		EQU	ESP+16
#Y1		EQU	ESP+12
#X1		EQU	ESP+8 
#RETADR		EQU	ESP+4 
#EBX		EQU	ESP

		PUSH	EBX
		MOV	EAX,[#X1]
		MOV	EBX,[#Y1]
		MOV	ECX,[#X2]
		MOV	EDX,[#Y2]
		CLIP	[#X]
		POP	EBX
		RET
AL_Crash_Polygon_Linear	ENDP
CODE		ENDS
			END

