		.386p
		ASSUME	CS:CODE

		PUBLIC	Projection

CODE		SEGMENT
		ALIGN	4
Projection	PROC
#PROJ		EQU	ESP+40
#SRCPTR		EQU	ESP+36
#DSTPTR		EQU	ESP+32
#NPOINT		EQU	ESP+28
#RETADR		EQU	ESP+24

#MAG		EQU	ESP+20
#CY		EQU	ESP+16
#CX		EQU	ESP+12

#ESI		EQU	ESP+8
#EDI		EQU	ESP+4
#EBX		EQU	ESP

		SUB	ESP,12
		PUSH	ESI
		PUSH	EDI
		PUSH	EBX

		MOV	ECX,[#PROJ]
		MOV	EAX,[ECX]
		MOV	EBX,[ECX+4]
		MOV	ECX,[ECX+8]
		MOV	[#CX],EAX
		MOV	[#CY],EBX
		MOV	[#MAG],ECX

		MOV	EAX,[#NPOINT]
		AND	EAX,EAX
		JE	#EXIT

		MOV	ESI,[#SRCPTR]
		MOV	EDI,[#DSTPTR]
		MOV	ECX,[#MAG]

		CMP	ECX,128
		JE	#MAG128

#LOOP0:		MOV	EBX,[ESI+8]
		MOV	EAX,[ESI]
		IMUL	ECX
		IDIV	EBX
		ADD	EAX,[#CX]
		MOV	[EDI],EAX
		MOV	EAX,[ESI+4]
		IMUL	ECX
		IDIV	EBX
		SUB	EAX,[#CY]
		NEG	EAX
		MOV	[EDI+4],EAX
		ADD	ESI,12
		ADD	EDI,8
		DEC	DWORD PTR [#NPOINT]
		JNE	#LOOP0

#EXIT:		POP	EBX
		POP	EDI
		POP	ESI
		ADD	ESP,12
		RET



#MAG128:
#LOOP1:		MOV	EBX,[ESI+8]
		MOV	EAX,[ESI]
		CDQ
		SHLD	EDX,EAX,7
		SHL	EAX,7
		IDIV	EBX
		ADD	EAX,[#CX]
		MOV	[EDI],EAX
		MOV	EAX,[ESI+4]
		CDQ
		SHLD	EDX,EAX,7
		SHL	EAX,7
		IDIV	EBX
		SUB	EAX,[#CY]
		NEG	EAX
		MOV	[EDI+4],EAX
		ADD	ESI,12
		ADD	EDI,8
		DEC	DWORD PTR [#NPOINT]
		JNE	#LOOP1

		POP	EBX
		POP	EDI
		POP	ESI
		ADD	ESP,12
		RET
Projection	ENDP
CODE		ENDS
		END
