      LOGICAL B1,B2,B3,B4,B5,B6,B7,B8,B9,B10
      DIMENSION FILE(2)
      COMMON/EYCEP/EYE(3),CEN(3),UP(3)
        COMMON/POINTS/INIT,PTS(6,80)
        COMMON/PULDAT/N
      COMMON/BULK/I3STRT,I3END,OBJ(6,80)
      COMMON/PAINT/I2STRT,I2END,PIC(4,80)
      COMMON/OIL/IVECT(800)
      COMMON/LIMITS/XMIN,XMAX,YMIN,YMAX
      DATA FILE(1),FILE(2)/4HCUBX,4H SRC/
      DATA ENFOR,EN2,EN3/5H(1X,2,5HHN=,I,2H4)/
      DATA EMFOR,EM2,EM3/5H(1X,3,5HHSET,,3HI2)/
      DATA IDS,IDL/2,1/
      CALL CLEAR(.TRUE.)
      CALL DISPLY (0,4000,IGET)
      CALL BUTTON(1)
      I3STRT=1
      I3END=80
      XMIN=-5.0
      XMAX=5.0
      YMIN=-5.0
      YMAX=5.0
      CALL SEEK (1,FILE)
      READ(1,501)((OBJ(I,J),I=1,6),J=1,78)
501   FORMAT (6F5.1)
      EYE(1)=0.0
      EYE(2)=0.0
      EYE(3)=10.0
      CEN(1)=0.0
      CEN(2)=0.0
      CEN(3)=0.0
      CX=CEN(1)
      CY=CEN(2)
      CZ=CEN(3)
      UP(1)=0.0
      UP(2)=10.0
      UP(3)=0.0
      DIST=8.0
      I2STRT=1
      I2END=80
      MODE=1
      NN=0
      RD=3.1415926/192.0
      CALL ROTER
      CALL MAPPER(DIST)
      CALL VECTOR(1,PIC,I2STRT,I2END,IVECT,1,LAST,7,0,0)
      CALL DISPLY(6,IDL,IVECT,1,LAST)
      CALL DISPLY(6,IDS,IVECT,1,LAST)
      CALL DISPLY(3,IDL)
      IH=IDS
      IDS=IDL
      IDL=IH
1     CALL TEXT(0,0,0,0,0)
      S=0
      CALL TEXT(800,100,7,1,EMFOR,S)
      CALL TEXT(800,900,7,1,ENFOR,NN)
      B1=.FALSE.
      B2=.FALSE.
      B3=.FALSE.
      B4=.FALSE.
      B5=.FALSE.
      B6=.FALSE.
      B7=.FALSE.
      CALL BUTTON(3,B1,B2,B3,B4,B5,B6,B7)
2     CALL BUTTON(2,B1,B2,B3,B4,B5,B6,B7)
      IF(B1) GO TO 15
      IF(B2) GO TO 25
      IF(B3) GO TO 33
      IF(B4) GO TO 40
      IF(B5) GO TO 50
      IF(B6) GO TO 60
      IF(B7) GO TO 70
      GO TO 2
40    DO 41 K=1,24
      CALL PULSE(N,N)
41    NN=NN+1
      GO TO 1
70    NN=0
      GO TO 1
50    CALL ZOOM(IDS,IDL,DIST,NN)
      GO TO 1
60    I3E=I3END
      I3END=1
      CALL ROTMAP(IDS,IDL,DIST)
      DO 61 K=1,576
      CALL PULSE(N,N)
61    NN=NN+1
      I3END=I3E
      CALL ROTMAP(IDS,IDL,DIST)
      GO TO 1
15    CALL TEXT(0,0,0,0,0)
      S=1
      CALL TEXT(800,100,7,1,EMFOR,S)
      CALL TEXT(800,900,7,1,ENFOR,NN)
10    B1=.FALSE.
      B2=.FALSE.
      B3=.FALSE.
      B4=.FALSE.
      B5=.FALSE.
      B6=.FALSE.
      B7=.FALSE.
      B8=.FALSE.
      B9=.FALSE.
      B10=.FALSE.
      CALL BUTTON(3,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10)
11    CALL BUTTON(2,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10)
      IF(B1) GO TO 110
      IF(B2) GO TO 120
      IF(B3) GO TO 130
      IF(B4) GO TO 140
      IF(B5) GO TO 1
      IF(B6) GO TO 160
      IF(B7) GO TO 170
      IF(B8) GO TO 180
      IF(B9) GO TO 190
      GO TO 11
25    CALL TEXT(0,0,0,0,0)
      S=2
      CALL TEXT(800,100,7,1,EMFOR,S)
      CALL TEXT(800,900,7,1,ENFOR,NN)
20    B1=.FALSE.
      B2=.FALSE.
      B3=.FALSE.
      B4=.FALSE.
      B5=.FALSE.
      B6=.FALSE.
      B7=.FALSE.
      B8=.FALSE.
      B9=.FALSE.
      CALL BUTTON(3,B1,B2,B3,B4,B5,B6,B7,B8,B9)
22    CALL BUTTON(2,B1,B2,B3,B4,B5,B6,B7,B8,B9)
      IF(B1) GO TO 210
      IF(B2) GO TO 220
      IF(B3) GO TO 230
      IF(B4) GO TO 240
      IF(B5) GO TO 1
      IF(B6) GO TO 260
      IF(B7) GO TO 270
      IF(B8) GO TO 280
      GO TO 22
33    CALL TEXT(0,0,0,0,0)
       S=3
      CALL TEXT(800,100,7,1,EMFOR,S)
      CALL TEXT(800,500,7,1,ENFOR,NN)
      B1=.FALSE.
      B2=.FALSE.
      B3=.FALSE.
      B4=.FALSE.
      B5=.FALSE.
      B6=.FALSE.
      B7=.FALSE.
      B8=.FALSE.
      B9=.FALSE.
      B10=.FALSE.
      CALL BUTTON(3,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10)
31    CALL BUTTON(2,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10)
      IF(B1) GO TO 310
      IF(B2) GO TO 320
      IF(B3) GO TO 330
      IF(B4) GO TO 340
      IF(B5) GO TO 1
      IF(B6) GO TO 360
      IF(B7) GO TO 370
      IF(B8) GO TO 380
      IF(B9) GO TO 390
      GO TO 31
110   GO TO 120
120   IK=48
      CPI=COS(+2.0*RD)
      SPI=SIN(+2.0*RD)
      GO TO 111
160   GO TO 170
170   IK=48
      CPI=COS(-2.0*RD)
      SPI=SIN(-2.0*RD)
111   DO 112 K=1,IK
      IF(B1.OR.B6) GO TO 113
      I3STRT=31
      I3END=55
113   CALL PIRX(CPI,SPI,CY,CZ)
      I3STRT=1
      I3END=80
      CALL ROTMAP(IDS,IDL,DIST)
      DO 112 KK=1,4
      CALL PULSE(N,N)
112   NN=NN+1
      GO TO 15
130   IK=48
140   IK=48
      CYA=COS(-1.0*RD)
      SYA=SIN(-1.0*RD)
      GO TO 131
180   IK=48
190   IK=48
      CYA=COS(+1.0*RD)
      SYA=SIN(+1.0*RD)
131   DO 132 K=1,IK
      IF(B3.OR.B8) GO TO 133
      I3STRT=56
133   CALL YARY(CYA,SYA,0.0,0.0)
      I3STRT=1
      CALL ROTMAP(IDS,IDL,DIST)
      DO 132 KK=1,4
      CALL PULSE(N,N)
132   NN=NN+1
      GO TO 15
210   IK=24
      CPI=COS(+2.0*RD)
      SPI=SIN(+2.0*RD)
      GO TO 211
260   IK=12
      CPI=COS(-4.0*RD)
      SPI=SIN(-4.0*RD)
211   DO 212 K=1,IK
      I3STRT=31
      I3END=55
      CALL PIRX(CPI,SPI,CY,CZ)
      CALL PIRX(CPI,SPI,CY,CZ)
      I3STRT=1
      CALL ROTMAP(IDS,IDL,DIST)
      CALL PULSE(N,N)
212   NN=NN+1
      GO TO 25
220   IK=48
      CYA=COS(-2.0*RD)
      SYA=SIN(-2.0*RD)
      GO TO 221
270   IK=48
      CYA=COS(+2.0*RD)
      SYA=SIN(+2.0*RD)
221   DO 222 K=1,IK
      I3STRT=56
      CRO=COS(+48.0*RD)
      SRO=SIN(+48.0*RD)
      CALL RORZ(CRO,SRO,CX,CY)
      CALL YARY(CYA,SYA,0.0,0.0)
      CRO=COS(-48.0*RD)
      SRO=SIN(-48.0*RD)
      CALL RORZ(CRO,SRO,CX,CY)
      I3STRT=1
      CALL ROTMAP(IDS,IDL,DIST)
      CALL PULSE(N,N)
222   NN=NN+1
      GO TO 25
230   IK=24
      CRO=COS(-2.0*RD)
      SRO=SIN(-2.0*RD)
      GO TO 231
280   IK=24
      CRO=COS(+2.0*RD)
      SRO=SIN(+2.0*RD)
231   DO 232 K=1,IK
      I3STRT=56
      CALL RORZ(CRO,SRO,0.0,0.0)
      I3STRT=1
      CALL ROTMAP(IDS,IDL,DIST)
      DO 232 KK=1,4
      CALL PULSE(N,N)
232   NN=NN+1
      GO TO 25
240   CALL ZOOM(IDS,IDL,DIST,NN)
      GO TO 25
310   GO TO 33
320   GO TO 33
330   GO TO 33
340   GO TO 33
360   GO TO 33
370   GO TO 33
380   GO TO 33
390   GO TO 33
      END
