	SUBROUTINE PLAY(ID)
C	ROUTINE TO CONTROL PLAYER`S MOVES
C----------------------standard common block----------------------------
C 
	COMMON ICR(8,12),IPARM(10),IS1,IS2,NT,ICU(10,10,10,2),CLEAR(8)
	COMMON MARKER(4,3,3)
	LOGICAL*1 ICU,CLEAR
C 
C-----------------------------------------------------------------------
	LOGICAL*1 ARR(6),ANS,BNS,CNS
	DIMENSION IRR(6)
	LUN=ICR(ID,8)
	I0=ICR(ID,10)
	J0=ICR(ID,11)
	K0=ICR(ID,12)
	IE=ICU(I0,J0,K0,2) ! GET CUBE ENERGY
	IG=30-ICR(ID,9)  ! ENERGY CAPACITY OF CRAWLER
	IF(IG-IE.LT.0) IE=IG  ! GET NO MORE THAN CAPACITY OF ENERGY
	ICU(I0,J0,K0,2)=ICU(I0,J0,K0,2)-IE ! REMOVE USED ENERGY FROM CUBE
	ICR(ID,9)=ICR(ID,9)+IE  ! STORE ENRGY FROM CUBE SPACE
C 
C	6-DIRECTION SCAN:
	ND=0  !  REDRAW SCREEN, DELAY
10	IF(ICR(ID,1).NE.1) GOTO 999   ! KILLED DURING MOVE OR LEFT CUBE
	CALL PSCAN(ID,ARR,IRA,ND)
	CALL MARK(ID,1) ! PRINT OUT TRANSMITTER DISTANCES
	ICE=ICU(ICR(ID,10),ICR(ID,11),ICR(ID,12),2)+IE  ! ENERGY STILL IN AREA
	WRITE(LUN,11) ICR(ID,9),IE,ICE,"33,CLEAR(ID)
11	FORMAT(
     C' | ENERGY LEVEL  |  ',I3,'  |',I3,'/',I3,' units absorbed |'/
     C' +-------+-------+-------+-------+-------+-------+'/
     C' (H,R,S,X,W,A,F,J,T,P,D,M,E,Z,Q,K,C,LIST) COMMAND: ',2A1,$)
	IE=0
	READ(LUN,12,END=999) ANS,BNS,CNS
12	FORMAT(3A1)
	IF(ANS.EQ.'A') GOTO 13
	IF(ANS.EQ.'M') GOTO 65
	IF(ANS.EQ.'E') GOTO 999
	IF(ANS.EQ.'F') GOTO 20
	IF(ANS.EQ.'S') GOTO 30
	IF(ANS.EQ.'X') GOTO 30
	IF(ANS.EQ.'W') GOTO 30
	IF(ANS.EQ.'R') GOTO 40
	IF(ANS.EQ.'Q') GOTO 90
	IF(ANS.EQ.'J') GOTO 120
	IF(ANS.EQ.'*') GOTO 130
	IF(ANS.EQ.'D') GOTO 115
	IF(ANS.EQ.'Z') GOTO 53
	IF(ANS.EQ.'T') GOTO 60
	IF(ANS.EQ.'P') GOTO 70
	IF(ANS.EQ.'+') GOTO 50
	IKEEP=2
	IF(ANS.EQ.'K') GOTO 150
	IF(ANS.EQ.'C') GOTO 151
	IF(ANS.EQ.'L'.AND.BNS.EQ.'I'.AND.CNS.EQ.'S') GOTO 140
	GOTO 110 ! HELP....
C 
C	REDRAW SCREEN
115	ND=1
	GOTO 10
C	KEEP GAME/ CONTINUE GAME
150	IKEEP=1
151	CALL SAVE(ID,IKEEP,TID1)
	GOTO 10
C 
C	PLACE/COLLECT TRANSMITTERS
60	CALL MARK(ID,0)
	GOTO 10
C 
C	SEND MESSAGES:
65	N=10  ! FLAG TO PSCAN TO GET TO MESSAGE SECTION
	CALL PSCAN(ID,ARR,IRR,N)
	ND=3  ! NO DELAY, OVERPRINT SCREEN (PSCAN)
	GOTO 10
C 
C	PROXIMITY SCANNER
70	CALL PROX(ID)
	GOTO 10
C	ADD EXTRA ENERGY
50	WRITE(LUN,51)
51	FORMAT(' <CR>',$)
	READ(LUN,52,ERR=10,END=999) EXTRA
52	FORMAT(F2.0)
	ICR(ID,9)=EXTRA
	ND=3
	GOTO 10
C 
C	ZZZZZ (PAUSE)
53	WRITE(LUN,54) "33,"33,CLEAR(ID)  ! CLEAR SCREEN
54	FORMAT(X,A1,'Y  ',2A1)
	PAUSE 'enter RESUME to continue'
	WRITE(LUN,55)  ! FOOL SYSTEM WHO TRIES TO MESS UP DISPLAY WITH ">"
55	FORMAT(' continuing')
	ND=1
	GOTO 10
110	CALL HELP(ID)
	ND=1  !  REDRAW SCREEN IN PSCAN, NO DELAY
	GOTO 10
C 
C	CHANGE PROGRAM PARAMETERS:
130	CALL PARMS(ID)
	ND=3
	GOTO 10
C 
C	RANDOM JUMP:
120	CALL JUMP(ID)
	ND=0  ! REDRAW SCREEN AND DELAY IN PSCAN
	GOTO 10
C 
C	ADVANCE:
13	IS=1
	IT=1
	IF(BNS.GE.'1'.AND.BNS.LE.'9') IT=BNS-48
	DO 14 I=1,IT
	CALL MOVE(ID,IS)
	IF(BNS.EQ.'X'.OR.CNS.EQ.'X') GOTO 15
	IF(I.EQ.IT) GOTO 15
	ND=3
	CALL PSCAN(ID,ARR,IRA,ND)
	CALL MARK(ID,1)
	WRITE(LUN,16) ICR(ID,9)-3,IE,ICE,"33,CLEAR(ID)
16	FORMAT(
     C' | ENERGY LEVEL  |  ',I3,'  |',I3,'/',I3,' units absorbed |'/
     C' +-------+-------+-------+-------+-------+-------+',2A1)
15	IF(ICR(ID,1).NE.1) GOTO 999  ! CRASHED OR OUT OF CUBE
14	CONTINUE
	IF(IT.GT.5.AND.BNS.NE.'X'.AND.CNS.NE.'X') ND=0
	IF(BNS.EQ.'E'.OR.CNS.EQ.'E') GOTO 999
	GOTO 10
C 
C	FIRE!
20	CALL FIRE(ID,BNS)
	ND=0
	GOTO 10
C 
C	SCANNER:
30	CALL SCAN(ID,ANS,BNS)
	ND=0
	GOTO 10
C 
C	ROTATE:
40	WRITE(LUN,41)
41	FORMAT(' direction (L,R,U,D): ',$)
	READ(LUN,43,END=999) ANS
43	FORMAT(A1)
	IF(ANS.LE.' ') GOTO 45
	IT=1
	IF(BNS.GE.'1'.AND.BNS.LE.'9') IT=BNS-48
	DO 42 I=1,IT
	CALL ROTATE(ANS,ID)
42	CONTINUE
	GOTO 10
45	WRITE(LUN,46)
46	FORMAT(' rotate aborted')
	GOTO 10
C 
C	LIST HELP FILE
140	CALL HLIST(LUN)
	ND=0
	GOTO 10
C 
C	PLAYER QUITS GAME:
90	WRITE(LUN,91)
91	FORMAT(' ARE YOU SURE YOU WANT TO QUIT NOW ?  ',$)
	READ(LUN,96,END=999) ANS
96	FORMAT(A1)
	IF(ANS.NE.'Y'.AND.ANS.NE.'y') GOTO 10
	ICR(ID,1)=0
	DO 92 I=1,8
	IF(ICR(I,1).NE.1.AND.ICR(I,1).NE.2) GOTO 92
	WRITE(ICR(I,8),93) ID
92	CONTINUE
93	FORMAT(' <crawler',I2,' has self-destructed>')
999	CALL CLOSE(5)
	RETURN
	END
