	SUBROUTINE STARS
C	GET AND STORE STAR PATTERN
	COMMON IB(10,10),IA(8,2),IC(8,2),NA,IS1,IS2,CHAR,CLEAR
	LOGICAL*1 CLEAR(6)
	LOGICAL*1 POS(4),ALPHA,IB,CHAR
	DIMENSION LOC(2)
	POS(1)="33
	POS(2)="131
1	WRITE(5,5)
	CALL CLOSE(5)
5	FORMAT(/////' * STAR PLACEMENT *'//)
3	WRITE(5,4)
4	FORMAT(//' There are four options for star placement:'/
     C' 1) Enter the stars from the terminal'/
     C' 2) Select a preset star pattern'/
     C' 3) Generate a random star pattern'/
     C' 4) Continue a saved game'/
     C' Enter 1, 2, 3 or 4: ',$)
	READ(5,6,END=303) ANS
6	FORMAT(A1)
	IF(ANS.EQ.'2') GOTO 100
	IF(ANS.EQ.'4') GOTO 400
	IF(ANS.NE.'1'.AND.ANS.NE.'3') GOTO 3
10	WRITE(5,11)
11	FORMAT(' How many stars do you wish to hide (1 to 8) ? ',$)
	READ(5,12,ERR=10,END=1) MA
12	FORMAT(I2)
	IF(MA.LE.0) RETURN
	IF(MA.GT.8) GOTO 10
	NA=MA
	IF(ANS.EQ.'3') GOTO 200
C	ANS=1:
9	WRITE(5,13) NA
13	FORMAT(' Now you must specify star locations.  When you hit'/
     C' <CR> the screen will clear and the game board will be drawn.'/
     C' Enter a star number, 1 through',I2,', and the location.  To'/
     C' change a star position, enter the star number with a new'/
     C' location.  Enter 0 or <CR> when done.')
	READ(5,6,END=1) ANS
	CALL BOARD
	POS(3)="40
	POS(4)="40
	WRITE(5,2) POS
2	FORMAT(X,4A1,'* STAR PLACEMENT *'//' star   location')
	CALL DSTARS(NA,IA,1)
	POS(4)="40
	DO 15 I=1,NA
	POS(3)=34+I
	WRITE(5,16) POS,I,IA(I,1)-1,34-IA(I,2)
15	CONTINUE
16	FORMAT(X,4A1,2X,I1,3X,I2,I4)
20	POS(3)=44
	POS(4)="40
	WRITE(5,17) POS,POS
17	FORMAT(X,4A1,6(25X/),X,4A1,'Star number, Location:'/16x/'+
     C*',X,$)
	READ(5,18,END=1,ERR=20) ISTAR,LOC
18	FORMAT(3I6)
	IF(ISTAR.LT.1.OR.ISTAR.GT.NA) GOTO 30 ! CHECK IF ENOUGH STARS
	IX=0
	IY=0
	DO 19 I=1,2
	IF(LOC(I).LT.9.AND.LOC(I).GT.0) IX=LOC(I)
	IF(LOC(I).GT.8.AND.LOC(I).LT.17) IY=LOC(I)-8+40
	IF(LOC(I).GT.16.AND.LOC(I).LT.25) IX=25-LOC(I)
	IF(LOC(I).GT.24.AND.LOC(I).LT.33) IY=33-LOC(I)+40
19	CONTINUE
	IF(IX.EQ.0.OR.IY.EQ.0) GOTO 20
	IY=IY-40
C 
C	NOW WE HAVE X AND Y STAR COORDINATES
	DO 118 I=1,NA
	IF(I.EQ.ISTAR) GOTO 118
	IF(IX+1.EQ.IA(I,1).AND.IY+1.EQ.IA(I,2)) GOTO 20
118	CONTINUE
	POS(3)=ISTAR+34
	POS(4)="40
	WRITE(5,16) POS,ISTAR,IX,33-IY
	ALPHA='-'
	IX1=IA(ISTAR,1)
	IY1=IA(ISTAR,2)
	IF(IX1.NE.0) CALL DBOARD(IX1,IY1,ALPHA)
	ALPHA='*'
	CALL DBOARD(IX+1,IY+1,ALPHA)
	IA(ISTAR,1)=IX+1
	IA(ISTAR,2)=IY+1
	GOTO 20
C 
C	CHECK TO SEE IF ALL STARS ENTERED:
30	DO 31 I=1,NA
	IF(IA(I,1).EQ.0.OR.IA(I,2).EQ.0) GOTO 20
31	CONTINUE
	POS(3)=44
	POS(4)="40
34	WRITE(5,32) POS
32	FORMAT('+',4A1,'Are you done entering'/' stars ?  Y/N-',$)
	READ(5,6,END=1) ANS
	IF(ANS.EQ.'Y'.OR.ANS.EQ.'y') GOTO 300
	GOTO 20
100	CALL PATS(I)
	IF(I.LE.0) GOTO 1
	WRITE(5,101) I
101	FORMAT(//' (pattern',I4,' selected)')
	GOTO 300
C 
C	RANDOM PATTERN GENERATOR
200	DO 203 I=1,NA
201	IX=RAN(IS1,IS2)*7.9999+2
	IY=RAN(IS1,IS2)*7.9999+2
	IF(IX.LT.2.OR.IX.GT.9.OR.IY.LT.2.OR.IY.GT.9) GOTO 201
	DO 202 J=1,I-1
	IF(IA(J,1).EQ.IX.AND.IA(J,2).EQ.IY) GOTO 201
202	CONTINUE
	IA(I,1)=IX
	IA(I,2)=IY
203	CONTINUE
	WRITE(5,204) NA
204	FORMAT(//X,I1,' stars have been randomly hidden.')
C 
C	STORE STARS IN BOX
300	DO 301 I=1,10
	DO 301 J=1,10
	IB(I,J)=' '
301	CONTINUE
	DO 310 I=1,8
	IC(I,1)=0
	IC(I,2)=0
310	CONTINUE
	DO 311 I=NA+1,8
	IA(I,1)=0
	IA(I,2)=0
311	CONTINUE
	DO 302 I=1,NA
	IB(IA(I,1),IA(I,2))='*'
302	CONTINUE
303	RETURN
C 
C	CONTINUE SAVED GAME:
400	I=0
	CALL USAVE(I)
	GOTO 303
	END
