C
C     THIS IS THE CAMERA CONTROL SUUBROUTINE
C        WHICH CONTROLS THE SHUTTER AND THE FILTERS
C        OF THE 16 MM BOLEX CAMERA
C     IT INCLUDES THE ROUTINE 'PULSE'
C        WHICH STORES THE FRAMES IF REGISTER SWITCH 16 IS UP
C        AND PLAYS THEM BACK AT 24 FRAMES/SEC IF SW 17 IS UP
C
C     FILMING IS INITIATED WHEN SW 15 IS UP
C        WITH STOP ACTION WHEN  SW 14 IS UP
C
C     THIS ROUTINE IS WATRAN COMPATIBLE
C     FOR PULSE   $A DK4  2
C         WATRAN  $A DK1 -5
C
C        COLOUR(I) = COLOUR OF TAG I
C
C              NA  = FIRST TAG
C              NB  = LAST TAG
C                       (ALL TAGS BETWEEN NA & NB ARE EXPOSED)
C              ADV = .TRUE. TO EXPOSE AND ADVANCE FILM
C                  = .FALSE. TO EXPOSE BUT NOT ADVANCE FILM
C
C      THE COLOURS AVAILABLE:
C
C           1 = RED
C           2 = BLUE
C           3 = GREEN
C           4 = MAGENTA
C           5 = CYAN
C           6 = YELLOW
C           7 = VIOLET
C           8 = WHITE
C
C       THE RELATIVE AMOUNT OF WHITE TO COLOUR
C       IS CONTROLLED BY THE EXPONENT:
C
C           1 = FULL RED
C           10 = 1/4 WHITE & 3/4 RED
C          100 = 1/2 WHITE & 1/2 RED
C          1000 = 3/4 WHITE & 1/4 RED
C
C
C
C
      SUBROUTINE CAMERA(NA,NB,COLOUR,ADV)
C
C
      LOGICAL ADV,ERR,ISENSW,RTEST,BTEST,GTEST
      INTEGER COLOUR(100),REDR(100),BLUER(100),GREENR(100)
      INTEGER INTENS(100),WHITER(100)
      ADV = .NOT. ADV
      RTEST = .FALSE.
      BTEST = .FALSE.
      GTEST = .FALSE.
C
  14  IF (ISENSW(14)) GO TO 14
C
C     SEND CALL TO PULSE
C
      CALL PULSE (IF1,IF2)
C
C     START FILMING IF SWITCH 15 IS DOWN
C
      IF (.NOT. ISENSW(15)) RETURN
C
C     TURN OFF ALL DISPLAY FILES
C
      DO 1000 I=NA,NB
      REDR(I) = 0
      BLUER(I) = 0
      GREENR(I) = 0
      WHITER(I) = 0
1000  CALL DISPLY(5,I)
      CALL DSTOP
C
C      NOW ASSIGN THE COLOUR VECTORS AND HUE LEVELS
C
      DO 10 I=NA,NB
      INTENS(I) = 0
      IREF = COLOUR(I)
  11  CONTINUE
      GO TO (1,2,3,4,5,6,7,8,9), IREF
      IREF = IREF/10
      INTENS(I) = INTENS(I) + 1
      GO TO 11
C
C     RED
C
   1  REDR(I) = 48 * (4 - INTENS(I)) / 4
      WHITER(I) = 8 * INTENS(I) / 4
      RTEST = .TRUE.
      GO TO 10
C
C     BLUE
C
   2  BLUER(I) = 16 * (4 - INTENS(I)) 
      WHITER(I) = 8 * INTENS(I) / 4
      BTEST = .TRUE.
      GO TO 10
C
C     GREEN
C
   3  GREENR(I) = 24 * (4 - INTENS(I)) / 4
      WHITER(I) = 8 * INTENS(I) / 4
      GTEST = .TRUE.
      GO TO 10
C
C     MAGENTA
C
   4  REDR(I) = 32 * (4 - INTENS(I)) / 4
      BLUER(I) = 16 * (4 - INTENS(I)) / 4
      WHITER(I) = 8 * INTENS(I) / 4
      RTEST = .TRUE.
      BTEST = .TRUE.
      GO TO 10
C 
C     CYAN
C
   5  GREENR(I) = 12 * (4 - INTENS(I)) / 4
      BLUER(I) = 4 * (4 - INTENS(I)) / 4
      WHITER(I) = 8 * INTENS(I) / 4
      GTEST = .TRUE.
      BTEST = .TRUE.
      GO TO 10
C
C     YELLOW
C
    6 REDR(I) = 64 * (4 - INTENS(I)) / 4
      GREENR(I) = 48 * (4 - INTENS(I)) / 4
      WHITER(I) = 8 * INTENS(I) / 4
      RTEST = .TRUE.
      GTEST = .TRUE.
      GO TO 10
C
C     ORANGE
C
   7  REDR(I) = 72 * (4 - INTENS(I)) / 4
      GREENR(I) = 24 * (4 - INTENS(I)) / 4
      WHITER(I) = 8 * INTENS(I) /4
      RTEST = .TRUE.
      GTEST = .TRUE.
      GO TO 10
C
C     VIOLET
C
   8  REDR(I) = 12 * (4 - INTENS(I)) / 4
      BLUER(I) = 6 * (4 - INTENS(I)) / 4
      WHITER(I) = 8 * INTENS(I) /4
      RTEST = .TRUE.
      BTEST = .TRUE.
      GO TO 10
C
C     WHITE
C
   9  WHITER(I) = 8
C
  10  CONTINUE
C
C     OPEN SHUTTER
C
      CALL SHUTTR(.TRUE.,ERR)
C
C     DO ALL THE REDS
C
      IF(.NOT. RTEST) GO TO 30
      CALL RED
      DO 70 I = 1,1000
 70   CONTINUE
C
C
      DO 100 I=NA,NB
      IREF = REDR(I)
      CALL DISPLY(4,I)
      CALL DPASS(IREF)
 100  CALL DISPLY(5,I)
C
C     DO ALL THE GREENS
C
 30   CONTINUE
      IF(.NOT. GTEST) GO TO 40
      CALL GREEN
      DO 80 I = 1,1000
 80   CONTINUE
C
C
      DO 200 I=NA,NB
      IREF = GREENR(I)
      CALL DISPLY(4,I)
      CALL DPASS(IREF)
 200  CALL DISPLY(5,I)
C
C     DO ALL THE BLUES
C
 40   CONTINUE
      IF (.NOT. BTEST) GO TO 50
      CALL BLUE
      DO 90 I = 1,1000
 90   CONTINUE
C
C
      DO 300 I=NA,NB
      IREF = BLUER(I)
      CALL DISPLY(4,I)
      CALL DPASS(IREF)
 300  CALL DISPLY(5,I)
C
C     FINALLY, DO ALL THE WHITES
C
 50   CALL SWITCH(1, .TRUE. ,2, .TRUE. ,3, .TRUE.)
C
      DO 55 I = 1,1000
 55   CONTINUE
C
C
      DO 400 I = NA,NB
      IREF = WHITER(I) 
      CALL DISPLY(4,I)
      CALL DPASS(IREF)
 400  CALL DISPLY(5,I)
C
C     CLOSE SHUTTER AND ADVANCE FILM IF REQUIRED
C
      CALL SHUTTR(.FALSE. ,ERR)
C
      DO 60 I = 1,1000
 60   CONTINUE
C
C     ACTIVATE THE DISPLAY AND RESET THE FILTERS
C
      CALL SWITCH(1, .FALSE. ,2, .FALSE. ,3, .FALSE.)
      DO 65 I = 1,1000
 65   CONTINUE
      CALL DGO
C
C     START ALL THE FILES AGAIN
C
      DO 2000 I=NA,NB
 2000 CALL DISPLY(4,I)
C
C     THAT'S IT
C
      RETURN
      END
C
