		.386p
		ASSUME	CS:CODE
		INCLUDE YGHASM.H

		PUBLIC	YGH_pagePartCopy

CODE		SEGMENT
		ALIGN	4
YGH_pagePartCopy	PROC
#LY		EQU	ESP+72
#LX		EQU	ESP+68
#SY		EQU	ESP+64
#SX		EQU	ESP+60
#SRC		EQU	ESP+56
#DY		EQU	ESP+52
#DX		EQU	ESP+48
#DST		EQU	ESP+44
#RETADR		EQU	ESP+40
#EBP		EQU	ESP+36
#ESI		EQU	ESP+32
#EDI		EQU	ESP+28
#EBX		EQU	ESP+24
#ES		EQU	ESP+20
#DS		EQU	ESP+16
#ESPOFS		EQU	16
#ESIOFS		EQU	ESP+12
#EDIOFS		EQU	ESP+8
#ESISTART	EQU	ESP+4
#EDISTART	EQU	ESP


		PUSH	EBP
		PUSH	ESI
		PUSH	EDI
		PUSH	EBX
		PUSH	ES
		PUSH	DS
		SUB	ESP,#ESPOFS

		MOV	ESI,[#SRC]
		MOV	EDI,[#DST]


		CMP	[#SX],DWORD PTR 0
		JGE	#SXisSet
		MOV	EAX,[#SX]
		NEG	EAX
		ADD	[#DX],EAX
		ADD	[#SX],EAX
		SUB	[#LX],EAX
		JLE	#EXIT
#SXisSet:
		CMP	[#DX],DWORD PTR 0
		JGE	#DXisSet
		MOV	EAX,[#DX]
		NEG	EAX
		ADD	[#DX],EAX
		ADD	[#SX],EAX
		SUB	[#LX],EAX
		JLE	#EXIT
#DXisSet:


		CMP	[#SY],DWORD PTR 0
		JGE	#SYisSet
		MOV	EAX,[#SY]
		NEG	EAX
		ADD	[#SY],EAX
		ADD	[#DY],EAX
		SUB	[#LY],EAX
		JLE	#EXIT
#SYisSet:
		CMP	[#DY],DWORD PTR 0
		JGE	#DYisSet
		MOV	EAX,[#DY]
		NEG	EAX
		ADD	[#SY],EAX
		ADD	[#DY],EAX
		SUB	[#LY],EAX
		JLE	#EXIT
#DYisSet:



		MOV	EAX,[ESI+YGH_WDX]
		SUB	EAX,[#SX]
		JLE	#EXIT
		CMP	EAX,[#LX]
		JGE	#LXisBeingSet
		MOV	[#LX],EAX
#LXisBeingSet:	MOV	EAX,[EDI+YGH_WDX]
		SUB	EAX,[#DX]
		JLE	#EXIT
		CMP	EAX,[#LX]
		JGE	#LXisSet
		MOV	[#LX],EAX
#LXisSet:


		MOV	EAX,[ESI+YGH_WDY]
		SUB	EAX,[#SY]
		JLE	#EXIT
		CMP	EAX,[#LY]
		JGE	#LYisBeingSet
		MOV	[#LY],EAX
#LYisBeingSet:	MOV	EAX,[EDI+YGH_WDY]
		SUB	EAX,[#DY]
		JLE	#EXIT
		CMP	EAX,[#LY]
		JGE	#LYisSet
		MOV	[#LY],EAX
#LYisSet:



		MOV	EAX,[ESI+YGH_WDX]
		SUB	EAX,[#LX]
		LEA	EAX,[EAX*2]
		MOV	[#ESIOFS],EAX
		MOV	EAX,[EDI+YGH_WDX]
		SUB	EAX,[#LX]
		LEA	EAX,[EAX*2]
		MOV	[#EDIOFS],EAX


		MOV	EAX,[ESI+YGH_ODW]
		IMUL	EAX,[#SY]
		ADD	EAX,[ESI+YGH_ADR]
		MOV	EBX,[#SX]
		LEA	EAX,[EAX+EBX*2]
		MOV	[#ESISTART],EAX

		MOV	EAX,[EDI+YGH_ODW]
		IMUL	EAX,[#DY]
		ADD	EAX,[EDI+YGH_ADR]
		MOV	EBX,[#DX]
		LEA	EAX,[EAX+EBX*2]
		MOV	[#EDISTART],EAX		


		MOV	EAX,[ESI+YGH_SEG]
		MOV	EBX,[EDI+YGH_SEG]
		MOV	DS,AX
		MOV	ES,BX
		MOV	ESI,[#ESISTART]
		MOV	EDI,[#EDISTART]
		MOV	EBX,[#LX]
		MOV	EDX,EBX
		SHR	EBX,1
		AND	DL,1

#LOOP0:		MOV	ECX,EBX
		REP	MOVSD
		AND	DL,1
		JE	#LOOP0OUT
		MOVSW
#LOOP0OUT:	ADD	ESI,[#ESIOFS]
		ADD	EDI,[#EDIOFS]
		DEC	DWORD PTR [#LY]
		JNE	#LOOP0

#EXIT:		ADD	ESP,#ESPOFS
		POP	DS
		POP	ES
		POP	EBX
		POP	EDI
		POP	ESI
		POP	EBP
		MOV	EAX,0
		RET
YGH_pagePartCopy	ENDP
CODE		ENDS
		END
