	INTEGER A, B, C, D, E, F, G, H, I, J, K, L, M
	INTEGER N, O, P, Q, R, S(2), T, U, V, W, X(2)
	INTEGER Y, Z, L9, N1, R1, SS, XX
	PRINT CHR$(26)
	L9=92
	DIM S(L9+1,L9+1), X(L9+1,L9+1), M$(72)
20	Y=0:A=0:SS=0
	INPUT "PATTERN FILE FOR INPUT";F$
	OPEN F$ AS 1
290	INPUT	"WHICH GENERATION SHALL THE DISPLAY START WITH";T
	INPUT	"AND THE LAST GENERATION";R1
	INPUT	"ALSO, HOW MANY SHALL I SKIP";O
	O=O+1
	FOR M=1 TO L9
360	READ #1; LINE MM$
	IF MM$="DONE"  OR MM$="END"  THEN 480
	IF LEN(MM$)<L9+1 THEN 400
	PRINT "NO MORE THAN "; L9; " CELLS PER LINE" : GOTO 1500
400	FOR R=1 TO LEN(MM$)
		IF MID$(MM$,R,1)=" " THEN 460
		IF MID$(MM$,R,1)<>"*" THEN 490
		S(M,R)=1
		A=A+1
		IF R>SS THEN SS=R
460	NEXT R
	NEXT M
480	GOTO 520
490	PRINT	"'";MID$(MM$,R,1);"' IS NEITHER A ' ' NOR A '*'";
	GOTO 1500
520	DIM X(L9+1,L9+1)
	IF Y<=0 THEN 550
	GOTO 20
550	DIM X(0,0)
	DIM X(L9+1,L9+1)
	V=0:G=0
	Y=M-1:N1=M-1
	PRINT CHR$(26);"GENERATION = 0  POPULATION =";A
	GOSUB 1020
610	G=G+1
	A=0:V=0
	FOR M=1 TO N1
		FOR R=1 TO SS
			J=0
			IF M>L9 OR R>L9 THEN 1370
			IF X(M,R+1)<=0 OR R=SS THEN 690
			J=J+1
690			IF X(M+1,R+1)<=0 OR M=N1 OR R=SS THEN 710
			J=J+1
710			IF X(M+1,R)<=0 OR M=N1 THEN 730
			J=J+1
730			IF M=N1 OR R=1 THEN 760
			IF X(M+1,R-1)<=0 THEN 760
			J=J+1
760			IF R=1 THEN 790
			IF X(M,R-1)<=0 THEN 790
			J=J+1
790			IF M=1 OR R=1 THEN 820
			IF X(M-1,R-1)<=0 THEN 820
			J=J+1
820			IF M=1 THEN 850
			IF X(M-1,R)<=0 THEN 850
			J=J+1
850			IF M=1 OR R=SS THEN 880
			IF X(M-1,R+1)<=0 THEN 880
			J=J+1
880			IF J=3 THEN 900
			IF J<>2 OR X(M,R)<=0 THEN 920
900			S(M,R)=1
			A=A+1
920		NEXT R
	NEXT M
	IF A=0 THEN 1340
	IF G=R1 THEN 970
	IF (G<T) OR (G-T)/O<>INT((G-T)/O) THEN 990
970	PRINT	CHR$(26); "GEN=" ;G; TAB(20); "POP=" ;A
	GOTO 1000
990	V=9
1000	GOSUB 1020
	GOTO 610
1020	J=90:A=90
	C=0:D=0
	FOR M=1 TO N1
		FOR R=SS TO 1 STEP -1
			IF S(M,R)<=0 THEN 1130
			IF M<J THEN J=M
			IF R<A THEN A=R
			IF M>C THEN C=M
			IF R>D THEN D=R
			IF V=9 THEN 1130
remark                           go graphics,  print circle, jump out, up a line
REMARK OUT.........	PRINT TAB(R);CHR$(27);"g";CHR$(13);CHR$(27);"G";CHR$(11)
			PRINT TAB(R);"*";CHR$(11)
1130		NEXT R
		IF CONSTAT% THEN GOTO 1600 ELSE GOTO 1160

1600		I%=INKEY
		WHILE NOT CONSTAT%
		WEND
		I%=INKEY
		IF I%=3 THEN GOTO 1380
		IF I%=112 THEN CHAIN "DUMP.COM"
		IF I%=80 THEN PRINTFLAG=1
1160		IF V=9 THEN 1170
		PRINT
1170	NEXT M
	IF PRINTFLAG=1 THEN CHAIN "DUMP.COM"
	IF G=R1 THEN 1350
	C=C-J+3
	D=D-A+3
	X(1,5)=3
	DIM X(0,0)
	DIM X(L9+1,L9+1)
	FOR M=1 TO N1
		FOR R=1 TO SS
			IF S(M,R)<=0 THEN 1270
			X(M-J+2,R-A+2)=1
1270		NEXT R
	NEXT M
	DIM S(0,0)
	DIM S(L9+1,L9+1)
	N1=C
	SS=D
	RETURN
1340    PRINT	"NO MORE LIFE IN GENERATION";G
1350	PRINT	"*** END OF RUN ***"
	GOTO 1380
1370	PRINT "CELL HAS REACHED LIMITS OF PROGRAM. PROGRAM MUST TERMINATE."
1380	PRINT
	INPUT "ANOTHER RUN";J$
	IF LEFT$(J$,1)="Y" THEN CHAIN "LIFE.COM" ELSE GOTO 1500
1500	END
