		.386p
		ASSUME CS:CODE
		INCLUDE YGHASM.H

		PUBLIC	YGH_getColor

CODE		SEGMENT
YGH_getColor	PROC
#Y		EQU	ESP+16
#X		EQU	ESP+12
#PAGE		EQU	ESP+8
#RETADR		EQU	ESP+4
#DS		EQU	ESP

		PUSH	DS
		MOV	EAX,[#PAGE]
		MOV	ECX,[#X]
		MOV	EDX,[#Y]

		AND	ECX,ECX
		JL	#RETURN0
		AND	EDX,EDX
		JL	#RETURN0
		CMP	ECX,[EAX+YGH_WDX]
		JGE	#RETURN0
		CMP	EDX,[EAX+YGH_WDY]
		JGE	#RETURN0

		IMUL	EDX,[EAX+YGH_ODW]
		ADD	EDX,[EAX+YGH_ADR]
		LEA	EDX,[EDX+ECX*2]

		MOV	ECX,[EAX+YGH_SEG]
		MOV	DS,CX
		MOVZX	EAX,WORD PTR [EDX]

#EXIT:		POP	DS
		RET

#RETURN0:	POP	DS
		SUB	EAX,EAX
		RET
YGH_getColor	ENDP

CODE		ENDS
		END
