C THIS SUBROUTINE CHOPS AND SCALES VALUES FOR THE ANALOG COMPUTER
C				BY J.A.SMITH
C				   DEPT. OF SYSTEMS DESIGN
	SUBROUTINE SCALE (I1STRT,I1END)
	COMMON/LIMITS/XMIN,XMAX,YMIN,YMAX
	COMMON/OUTPUT/LINE(4,300)
	COMMON/PAINT/I2STRT,I2END,PICT(4,300)
	COMMON/INTERN/ISW1,ISW2,ISW3,ISW4,ISW5,X,Y,XSTART,
	1XEND,YSTART,YEND,XBEGIN,YBEGIN,XFINAL,YFINAL
C
C  D-A CHANNEL NUMBERS ARE:
	CHAN0=00000.
	CHAN1=04096.
	CHAN2=08192.
	CHAN3=12288.
C
C  THE SCALING FACTORS FOR INITIAL CONDITIONS & DELTAS X & Y ARE:
	XS1=4095.0/(XMAX-XMIN)
	YS1=4095.0/(YMAX-YMIN)
C
	L=I1STRT-1
C
	DO 3 I=I2STRT,I2END
	XBEGIN=PICT(1,I)
	YBEGIN=PICT(2,I)
	XFINAL=PICT(3,I)
	YFINAL=PICT(4,I)
	CALL XYLIM
	IF (ISW3.EQ.1) GO TO 3
	L=L+1
C SCALE THE NUMBERS TO THE D/A RANGE OF 0-4095
C ADD IN THE CHANNEL NUMBERS.
	LINE(1,L)=(XSTART-XMIN)*XS1+.5+CHAN0
	LINE(2,L)=(YSTART-YMIN)*YS1+.5+CHAN1
	LINE(3,L)=(XEND-XMIN)*XS1+.5+CHAN2
	LINE(4,L)=(YEND-YMIN)*XS1+.5+CHAN3
3	CONTINUE
	I1END=L
	RETURN
	END
