	SUBROUTINE OSCAN2(ID,I0,J0,IOUT,IM)
C	ROUTINE TO SCAN DOORWAYS IN OUTSIDE WORLD
C	THIS ONE FILLS UP IOUT ARRAY USING ARR.
C	IM=1 IF ON DOORWAY, ELSE 0
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(40,30),IOUT(61,5),C
	LUN=ICR(ID,8)
	CALL DIREC(ID,'a',1,JF)
	CALL DIREC(ID,'a',5,JU)
	CALL DIREC(ID,'a',2,JL)
	K=1
C	JF IS FORWARD DIRECTION, JU IS UP.  JL IS LEFT.
	IF(JF.NE.5.AND.JF.NE.6.AND.JU.NE.5.AND.JU.NE.6) GOTO 10
	IF(JF.NE.1.AND.JF.NE.3.AND.JU.NE.1.AND.JU.NE.3) GOTO 20
	IF(JF.NE.2.AND.JF.NE.4.AND.JU.NE.2.AND.JU.NE.4) GOTO 30
1	RETURN
C 
C	5 ON LEFT, 6 ON RIGHT, 1,2,3,4 IN VIEW:
10	DO 11 I=1,10
	DO 11 J=1,10
	ARR(30+I,J)=ICU(J,11-I,10,1)
	ARR(30+I,10+J)=ICU(10,11-I,11-J,1)
	ARR(30+I,20+J)=ICU(11-J,11-I,1,1)
C 
	ARR(20+I,J)=ICU(I,J,10,1)
	ARR(20+I,10+J)=ICU(I,10,11-J,1)
	ARR(20+I,20+J)=ICU(I,11-J,1,1)
C 
	ARR(10+I,J)=ICU(11-J,I,10,1)
	ARR(10+I,10+J)=ICU(1,I,11-J,1)
	ARR(10+I,20+J)=ICU(J,I,1,1)
C 
	ARR(I,J)=ICU(11-I,11-J,10,1)
	ARR(I,10+J)=ICU(11-I,1,11-J,1)
	ARR(I,20+J)=ICU(11-I,J,1,1)
11	CONTINUE
	IF(JL.EQ.5) K=-1
	GOTO 40
C 
C	1 ON LEFT, 3 ON RIGHT, 2,5,4,6 IN VIEW:
20	DO 21 I=1,10
	DO 21 J=1,10
	ARR(30+I,J)=ICU(10,J,11-I,1)
	ARR(30+I,10+J)=ICU(11-J,10,11-I,1)
	ARR(30+I,20+J)=ICU(1,11-J,11-I,1)
C 
	ARR(20+I,J)=ICU(10,I,J,1)
	ARR(20+I,10+J)=ICU(11-J,I,10,1)
	ARR(20+I,20+J)=ICU(1,I,11-J,1)
C 
	ARR(10+I,J)=ICU(10,11-J,I,1)
	ARR(10+I,10+J)=ICU(11-J,1,I,1)
	ARR(10+I,20+J)=ICU(1,J,I,1)
C 
	ARR(I,J)=ICU(10,11-I,11-J,1)
	ARR(I,10+J)=ICU(11-J,11-I,1,1)
	ARR(I,20+J)=ICU(1,11-I,J,1)
21	CONTINUE
	IF(JL.EQ.1) K=-1
	GOTO 40
C 
C	4 ON LEFT, 2 ON RIGHT, 1,5,3,6 IN VIEW:
30	DO 31 I=1,10
	DO 31 J=1,10
	ARR(30+I,J)=ICU(J,1,11-I,1)
	ARR(30+I,10+J)=ICU(10,J,11-I,1)
	ARR(30+I,20+J)=ICU(11-J,10,11-I,1)
C 
	ARR(20+I,J)=ICU(I,1,J,1)
	ARR(20+I,10+J)=ICU(I,J,10,1)
	ARR(20+I,20+J)=ICU(I,10,11-J,1)
C 
	ARR(10+I,J)=ICU(11-J,1,I,1)
	ARR(10+I,10+J)=ICU(1,J,I,1)
	ARR(10+I,20+J)=ICU(J,10,I,1)
C 
	ARR(I,J)=ICU(11-I,1,11-J,1)
	ARR(I,10+J)=ICU(11-I,J,1,1)
	ARR(I,20+J)=ICU(11-I,10,J,1)
31	CONTINUE
C 
	IF(JL.EQ.4) K=-1
C 
C	HAVE ARRAY ARR FILLED.  IF K=-1, SCAN IN INVERTED ORDER.
40	IC=I0
	DO 52 I=1,61
	DO 53 J=1,5
	IOUT(I,J)=' '
53	CONTINUE
	IOUT(1,J)='|'
	IOUT(61,J)='|'
52	CONTINUE
	DO 51 I=1,40
C	IF K=1, SCAN FORWARD; ELSE SCAN BACKWARD
	IC=IC+K
	IF(IC.GT.40) IC=1 ! WRAPAROUND
	IF(IC.LT.1) IC=40 !     "  "
	DO 51 J=1,30
	J1=J
	IF(K.EQ.-1) J1=31-J
	IF(ARR(IC,J1).NE.'[') GOTO 51  ! NO DOORWAY ON THAT SPOT
	X=I
	X=(J1-J0)/X
	X=ATAN(X)
	IF(X.GT..5235988.OR.X.LT.-.5235988) GOTO 51  ! ANGLE OUT OF RANGE
C 
C	-30     -20     -10     -0-    +10     +20     +30
C	 1       11      21     31      41      51      61
C 
C	X IS NOW RADIANS, +/- 30 DEGREES.  SCALE TO 1 TO 61:
	IDEG=57.295779513 * X  +  31.5
	X=I*I+(J1-J0)**2
	X=SQRT(X)  ! DISTANCE TO DOORWAY
	JD=1
	IF(X.LT.23) JD=2
	IF(X.LT.17) JD=3
	IF(X.LT.11) JD=4
	IF(X.LT.5) JD=5
	IF(IOUT(IDEG,JD).NE.' ') GOTO 51
	C='('
	IF(X.LT.19) C='{'
	IF(X.LT.8) C='['
	IOUT(IDEG,JD)=C
51	CONTINUE
C 
	IM=0
	IF(IPARM(9).EQ.1) WRITE(LUN,480) I0,J0
480	FORMAT(' I0,J0:',2I5)
	IF(ARR(I0,J0).EQ.'[') IM=1  ! ON DOORWAY
	ARR(I0,J0)='*'
	IF(IPARM(9).EQ.0) GOTO 1  ! RETURN
C	DEBUGS:
	WRITE(LUN,499)
499	FORMAT(' -',$)
	READ(LUN,501) C
	IF(C.EQ.' ') GOTO 1
	WRITE(LUN,500) ((ARR(I,J),J=1,30),I=1,20)
500	FORMAT(2(10(3(10(X,A1),' |')/)3(' - - - - - - - - - -  ')/))
	READ(LUN,501) C
501	FORMAT(A1)
	WRITE(LUN,500) ((ARR(I,J),J=1,30),I=21,40)
	READ(LUN,501) C
	WRITE(LUN,502) "33,"33,CLEAR(ID)
502	FORMAT(X,A1,'Y  ',2A1)
	GOTO 1  ! RETURN
	END
