	SUBROUTINE PSCAN(ID,ARR,IRA,ND)
C 
C	ND=0,1,2 or 3:
C	ROUTINE TO GIVE 6-DIRECTION SCAN AT START OF EACH MOVE
C	I,J,K ARE SCAN INCREMENTS;  SCAN IN DIRECTION OF INCR.
C	UNTIL OBJECT OR WALL IS FOUND; REPORT OBJECT AND DISTANCE
C		CLEAR SCREEN	DELAY	SET ND TO
C	ND=0:	     X		  X	     2
C	ND=1:	     X		  -	     2
C	ND=2:	     -            X	     2
C	ND=3:	     -		  -	     2
C	================================================================
C 
C 
C	ND=10:
C	ROUTINE TO ALLOW PLAYERS TO SEND MESSAGES TO OTHER CRAWLERS
C 
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-----------------------------------------------------------------------
C	FOR MESSAGES:
	LOGICAL*1 STUFF(80,3)
C	FOR SCANS:
	LOGICAL*1 ARR(6),C,A
	DIMENSION IRA(6)
C 
	LUN=ICR(ID,8)
	IF(ND.EQ.10) GOTO 500
C 
	C=ICU(ICR(ID,10),ICR(ID,11),ICR(ID,12),1)
	IDOOR=0
	IF(C.GT.'8'.AND.C.LT.'C') IDOOR=1 ! CRAWLER ON DOOR SPACE
	IUFO=-1  ! 1 IF UFO FOUND
	DO 100 M=1,6
	CALL DIREC(ID,C,M,N)
	I=0
	J=0
	K=0
	IF(N.EQ.1) I=1
	IF(N.EQ.2) J=1
	IF(N.EQ.3) I=-1
	IF(N.EQ.4) J=-1
	IF(N.EQ.5) K=1
	IF(N.EQ.6) K=-1
	I0=ICR(ID,10)
	J0=ICR(ID,11)
	K0=ICR(ID,12)
	LUN=ICR(ID,8)
	DO 1 N=1,11
	I0=I0+I
	J0=J0+J
	K0=K0+K
	IF(I0.GT.10.OR.I0.LT.1) GOTO 5 ! WALL....
	IF(J0.GT.10.OR.J0.LT.1) GOTO 5
	IF(K0.GT.10.OR.K0.LT.1) GOTO 5
	C=ICU(I0,J0,K0,1)
	IF(C.NE.' ') GOTO 8
1	CONTINUE
8	IF(C.GT.'8'.AND.C.LT.'C') C=C-10  ! CRAWLER BLOCKING DOORWAY
	IF(C.GT.'0'.AND.C.LT.'9') GOTO 22
	IF(C.EQ.'*') GOTO 22
	IF(C.EQ.'[') GOTO 22
	IF(C.NE.'['.AND.C.NE.'*'.AND.(C.LT.'1'.OR.C.GT.'8'))GOTO 24
22	ARR(M)=C
	IRA(M)=N
	GOTO 100
23	ARR(M)=C
	IRA(M)=N+1
	GOTO 100
24	ARR(M)='?'
	IRA(M)=N
	IUFO=N
	A=C
	GOTO 100
5	ARR(M)='w'
	IRA(M)=N-1
100	CONTINUE
C 
C	TALLY ACTIVE CRAWLERS:
	I=0
	J=0
	K=0
	L=0
	DO 201 IP=1,8
	IQ=ICR(IP,1)
	IF(IQ.EQ.1) I=I+1
	IF(IQ.EQ.2) J=J+1
	IF(IQ.EQ.3) K=K+1
	IF(IQ.EQ.4) L=L+1
201	CONTINUE
C 
	IF(ICR(ID,1).GT.2.AND.IPARM(1).EQ.1) RETURN ! SUPPRESS C-C MESSAGES
C 
	X=0.
	IF(ICR(ID,1).LT.3) GOTO 200
	IF(IPARM(2).EQ.9) X=.01  ! "NO" DELAY (WOULD YOU BELIEVE A SMALL ONE ?)
	IF(IPARM(2).LT.9) X=IPARM(2)  ! 0 FOR <CR>, ELSE DELAY TIME
200	IF(ND.NE.1.AND.ND.NE.3) CALL DELAY(X,LUN,C)
	IF(ND.LT.2) WRITE(LUN,1001) "33,"33,CLEAR(ID)
	ND=2
1001	FORMAT(X,A1,'Y  ',2A1)
1002	FORMAT(X,A1,'Y  ')
	WRITE(LUN,101) "33,ID,NT,I,J,K,L,ARR(1),IRA(1),ARR
     C(2),IRA(2),ARR(3),IRA(3),ARR(4),IRA(4),ARR(5),IRA(5),ARR(6),IRA(6)
101	FORMAT(X,A1,'Y  +-------+-------+-------+-------+-------+------
     C-+'/' | CRAWLER',I5,'  |  T',I3,' |ACTIVE:| P ',I1,X,I1,' | C ',I1
     C,X,I1,' |'/
     C' +-------+-------+-------+-------+-------+-------+'/
     C' | front | left  | back  | right |  up   | down  |'/
     C' +-------+-------+-------+-------+-------+-------+'/
     C' |',6(X,'(',A1,')',I2,' |')/
     C' +-------+-------+-------+-------+-------+-------+')
	IF(IUFO.NE.-1) WRITE(LUN,102) A,IUFO
102	FORMAT(' | Last unidentified object "',O3,' | range |',I4,'   |'
     C/' +-------+-------+-------+-------+-------+-------+')
	IF(NT.LT.4) WRITE(LUN,113)
113	FORMAT(' | <all crawler shields activated until turn 4>  |'/
     C' +-------+-------+-------+-------+-------+-------+')
	IF(IDOOR.EQ.0) GOTO 103
C 
C	DETERMINE DIRECTION OF DOOR:
	I=0
	IF(ICR(ID,10).EQ.10) I=1
	IF(ICR(ID,10).EQ.1)  I=3
	IF(ICR(ID,11).EQ.10) I=2
	IF(ICR(ID,11).EQ.1)  I=4
	IF(ICR(ID,12).EQ.10) I=5
	IF(ICR(ID,12).EQ.1)  I=6
	IF(I.EQ.0) GOTO 110
C 
C	FIND DIRECTION RELATIVE TO CRAWLER
	IF(ICR(ID,2).EQ.I) D='fwd.'
	IF(ICR(ID,3).EQ.I) D='left'
	IF(ICR(ID,4).EQ.I) D='back'
	IF(ICR(ID,5).EQ.I) D='rt. '
	IF(ICR(ID,6).EQ.I) D='up  '
	IF(ICR(ID,7).EQ.I) D='down'
	WRITE(LUN,104) D
104	FORMAT(' | EXIT POSSIBLE |       |   access door is ',A4,' |'/
     C' +-------+-------+-------+-------+-------+-------+')
C 
103	IF(IPARM(7).EQ.1) WRITE(LUN,14) CLEAR(ID),(ICR(ID,J),J=1,12)
14	FORMAT(' |internal status| <',A1,'-',I1,'> |D',6I1,'|
     CL',I1,'EX',I3,'|C',3I2,'|'/
     C' +-------+-------+-------+-------+-------+-------+')
	IF(IPARM(8).EQ.1) WRITE(LUN,15) (ICR(J,8),J=1,8)
15	FORMAT(' | scanner frequencies   |',I2,7I3,'|'/
     C' +-------+-------+-------+-------+-------+-------+')
C 
C 
C 
	RETURN
110	WRITE(LUN,111)
111	FORMAT(' [PSCAN thinks crawler is on door area but crawler'/
     C' is not at any cube face]')
	GOTO 103
C 
C 
C 
C	MESSAGES SECTION:
500	WRITE(LUN,502)
502	FORMAT(' radio on.  crawler to receive message: ',$)
	READ(LUN,503,ERR=1) JD
503	FORMAT(I1)
	IF(JD.LE.0) GOTO 520
	IF(ICR(JD,1).NE.0) GOTO 505
	WRITE(LUN,504) JD
504	FORMAT(' crawler',I2,' is not active')
	GOTO 500
505	WRITE(LUN,506)
506	FORMAT(' enter message, up to three lines.  end with a #.')
	J=1
507	READ(LUN,508) (STUFF(I,J),I=1,80)
508	FORMAT(80A1)
	DO 509 I=1,79
	IF(STUFF(I,J).EQ.'#') GOTO 510
509	CONTINUE
	J=J+1
	IF(J.LE.3) GOTO 507
	J=3
510	WRITE(LUN,541) JD,ID
541	FORMAT(' :: crawler',I2,' receiving message from',I2' ::')
	DO 511 I=1,J
	KN=-1
	DO 512 K=1,79
	IF(STUFF(K,I).EQ.'#') KN=K-1
512	CONTINUE
	DO 612 K=1,79
	L=80-K
	IF(STUFF(L,I).GT.' ') GOTO 613
612	CONTINUE
613	IF(KN.GE.0) L=KN
	WRITE(ICR(JD,8),515) (STUFF(K,I),K=1,L)
515	FORMAT(X,79A1)
511	CONTINUE
519	RETURN
520	WRITE(LUN,521)
521	FORMAT(' message aborted')
	GOTO 519
	END
