C CHECK COORDINATES TO SEE IF THEY LIE WITHIN LIMITS
C				BY S. MIDDLESTADT
C				   DEPT. OF SYSTEMS DESIGN
	SUBROUTINE XYLIM
	COMMON /LIMITS/ XMIN,XMAX,YMIN,YMAX
	COMMON /INTERN/ISW1,ISW2,ISW3,ISW4,ISW5,X,Y,XSTART,
	1XEND,YSTART,YEND,XBEGIN,YBEGIN,XFINAL,YFINAL
	ISW1=0
	ISW2=0
	ISW3=0
C CHECK TO SEE IF LINE WITHIN SCREEN LIMITS
	IF(XBEGIN.LT.XMIN.AND.XFINAL.LT.XMIN) GO TO 5
	IF(XBEGIN.GT.XMAX.AND.XFINAL.GT.XMAX) GO TO 5
	IF(YBEGIN.LT.YMIN.AND.YFINAL.LT.YMIN) GO TO 5
	IF(YBEGIN.GT.YMAX.AND.YFINAL.GT.YMAX) GO TO 5
	GO TO 7
 5	ISW3=1
	GO TO 60
C CHECK TO DETERMINE WHETHER POINTS ARE  
C          INSIDE OR OUTSIDE OF DEFINED LIMITS
 7	IF(XBEGIN.GE.XMIN.AND.XBEGIN.LE.XMAX) GO TO 10
	ISW1=1
	GO TO 20
10	IF(YBEGIN.GE.YMIN.AND.YBEGIN.LE.YMAX) GO TO 20
	ISW1=1
20	IF(XFINAL.GE.XMIN.AND.XFINAL.LE.XMAX) GO TO 30
	ISW2=1
	GO TO 40
30	IF(YFINAL.GE.YMIN.AND.YFINAL.LE.YMAX) GO TO 50
	ISW2=1
50	IF(ISW1.EQ.1.OR.ISW2.EQ.1)GO TO 40
	GO TO 55
C GO TO SUBROUTINE TO START CALCULATION
C FOR INTERSECTION POINTS
40	CALL NEWPTS
	GO TO 60
55	XSTART=XBEGIN
	YSTART=YBEGIN
	XEND=XFINAL
	YEND=YFINAL
60	RETURN
	END
