       SUBROUTINE TORPS
C** FIRE TORPEDOES
       COMMON /GENDTA/SDATA,COND(2),KLING,TMLEFT,ITORP,ENERGY,SHELDS
       COMMON /QUAD/IQAD(8,8),IQX,IQY
       COMMON /SECT/SEC(64,64),ISX,ISY,ISX8,ISY8
        COMMON /DAMAGS/IRPARS(10,2),IRAND,IRATE,IDMGD,TSTRT,GTIME
       COMMON /RMULN/IRMLN,IRMX,IRMY,IHTMS
       DATA BLNK/'    '/
       IF(IRPARS(3,1) .LE. 0)GO TO 10
       TYPE *,'**TORPEDO TUBES DAMAGED. NO TORPEDOES CAN BE FIRED'
       GO TO 999
 10    TYPE 1001
 1001  FORMAT($,' TORPEDO COURSE> ')
       ACCEPT *,COURSE
       IF(COURSE .EQ. 0.0)GO TO 999
       IF(COURSE .LT. 1.0 .OR. COURSE .GE. 9.0)GO TO 10
       ENERGY = ENERGY - 0.5
       ITORP = ITORP - 1
       ANGLE =(COURSE-1)/8.0 *2.0*3.14159
       TYPE 1002,ISX,ISY
 1002  FORMAT(' TORPEDO FIRED FROM SECTOR (',I3,',',I3,')')
C** SEARCH AN INVERTED GRID THROUGH A QUARTER QUADRANT TYPE SEARCH.
C**           COS - : COS +
C**           SIN + : SIN +
C**           .............
C**           COS - : COS +
C**           SIN - : SIN -
C**
       IDELX = 1
       IDELY = 1
       IF(COURSE .GT. 3.0 .AND. COURSE .LT. 7.0)IDELX =-1
       IF(COURSE .LT. 5.0)IDELY =-1
       IXD = ISX
       IYD = ISY
       DO 200 I=1,4
       DO 220 J=1,4
       IF(SEC(IXD,IYD) .EQ. '    ')GO TO 210
       XDIST = (I-1)*IDELX
       YDIST = (J-1)*IDELY
       IF(XDIST .EQ. 0.0 .AND. YDIST .EQ. 0.0)GO TO 210
       ANGL2 = ATAN2(-YDIST,XDIST)
       IF(ANGL2. LT. 0.0)ANGL2 = ANGL2+2.*3.14159
       IF(ANGL2 .GE. ANGLE -.01 .AND. ANGL2 .LE. ANGLE +.01)GO TO 500
 210   IYD = IYD + IDELY
       IF(IYD .EQ. 0)IYD=64
       IF(IYD .EQ. 65)IYD=1
 220   CONTINUE
       IXD = IXD + IDELX
       IF(IXD .EQ. 0)IXD=64
       IF(IXD .EQ. 65)IXD=1
       IYD = ISY
 200   CONTINUE
       TYPE *,' TORPEDO MISSED AND EXPLODED HARMLESSLY IN SPACE'
       GO TO 999
C** SCORED A HIT
 500   IF(SEC(IXD,IYD) .EQ. ' * ')GO TO 510
       IF(SEC(IXD,IYD) .EQ. '(R)')GO TO 520
       IF(SEC(IXD,IYD) .EQ. ':B:')GO TO 530
       TYPE *,' *** TORPEDO HAS HIT THE KLINGON'
       TYPE *,' *** KLINGON DESTROYED***'
       SEC(IXD,IYD) = BLNK
       KLING = KLING - 1
       IT = (IXD-1)/8 +1
       IS = (IYD - 1)/8 +1
       IQAD(IT,IS) = IQAD(IT,IS) - 100
C** DIAGNOSTIC ERROR
       IF(IQAD(IT,IS) .GE. 0)GO TO 999
       TYPE 9001,IT,IS,IXD,IYD
 9001  FORMAT(' *** ERROR QUAD = ',2I5,' SECTOR = ',2I5)
       IQAD(IT,IS) = 0
       GO TO 999
 510   TYPE *,' TORPEDO HAS BEEN PULLED OFF COURSE BY THE'
       TYPE *,' STAR AND HAS EXPLODED IN THE STAR.'
 515   TYPE *,' A LOSS OF ENERGY IS EXPERIENCED BY YOUR'
       DELX = ISX-IXD
       DELY = ISY-IYD
       DIST=SQRT(DELX**2 + DELY**2)
       IF(DIST .GE. 7.0)DIST = 6.0
        AFFECT = (7.0-DIST)/7.0 * 200.
       SHELDS = SHELDS - AFFECT
       TYPE 1005,AFFECT,SHELDS
 1005  FORMAT(' SHIELDS OF ',F9.2,' LEAVING ',F7.2)
       GO TO 999
C**
 520   TYPE *,' TORPEDO HAS HIT THE ROMULAN SHIP'
       TYPE *,' ****** THE ROMULAN IS DESTROYED  ***'
       SEC(IXD,IYD) = BLNK
       IRMX = 0
       IRMY = 0
       GO TO 999
C**
 530   TYPE *,' STAR BASE SHIELDS PROTECT IT FROM TORPEDO FIRE'
        GO TO 515
C**  SEARCH FOR KLINGONS TO FIRE BACK
 999   CALL RFIRE
       RETURN
       END