/* strek_main.f -- translated by f2c (version of 19 December 1990  16:50:21).
   You must link the resulting object file with the libraries:
	-lF77 -lI77 -lm -lc   (in that order)
*/

#include "f2c.h"

/* Common Block Declarations */

struct {
    char means[90];
} key_defs__;

#define key_defs__1 key_defs__

/* Table of constant values */

static integer c__0 = 0;
static integer c__3 = 3;
static integer c__1 = 1;
static real c_b38 = (float)1.;
static real c_b39 = (float).6;
static integer c__7 = 7;

/* Main program */ MAIN__()
{
    /* Initialized data */

    static integer index[10] = { 1,2,3,4,5,5,5,6,6,6 };
    static integer cm[3] = { 0,0,0 };
    static integer cs[3] = { 0,0,0 };
    static integer pc[3] = { 3,3,3 };
    static real rot_azm__[10] = { (float)0.,(float)-2.,(float)2.,(float)0.,(
	    float)0.,(float)-1.,(float)1.,(float)0.,(float)0.,(float)0. };
    static real rot_ang__[10] = { (float)2.,(float)0.,(float)0.,(float)-2.,(
	    float)1.,(float)0.,(float)0.,(float)-1.,(float)0.,(float)0. };
    static real rot_cost__[10] = { (float).25,(float).25,(float).25,(float)
	    .25,(float).25,(float).25,(float).25,(float).25,(float)0.,(float)
	    .25 };
    static logical rotate = TRUE_;
    static integer r_index__ = 9;
    static real photon_tr__[6] = { (float)900.,(float)900.,(float)900.,(float)
	    900.,(float)900.,(float)900. };
    static real xc = (float)0.;
    static shortint key_set__[16] = { 65535,65535,65535,65535,65535,65535,
	    65535,65535,65535,65535,65535,65535,65535,65535,65535,65535 };
    static real yc = (float)-50.;
    static real zc = (float)0.;
    static real azm = (float)0.;
    static real angle = (float)0.;
    static integer photons = 20;
    static real speed = (float)0.;
    static real energy = (float)1e3;
    static real damage = (float)0.;
    static real d_pct__[6] = { (float)1.,(float)1.,(float)1.,(float)1.,(float)
	    1.,(float)1. };
    static real odamage[10] = { (float)0.,(float)0.,(float)0.,(float)0.,(
	    float)0.,(float)0.,(float)0.,(float)0.,(float)0.,(float)0. };
    static integer ship_k__ = 0;
    static real tr_cost__[10] = { (float)0.,(float).4,(float)2.,(float)2.,(
	    float)1.,(float)1.,(float)1.,(float)1.,(float)1.,(float)1. };
    static real obx[10] = { (float)0. };
    static real oby[10] = { (float)0. };
    static real obz[10] = { (float)0. };
    static real ospeed[10] = { (float)0.,(float)0.,(float)0.,(float)0.,(float)
	    0.,(float)0.,(float)0.,(float)0.,(float)0.,(float)0. };
    static real oangle[10] = { (float)0.,(float)0.,(float)0.,(float)0.,(float)
	    0.,(float)0.,(float)0.,(float)0.,(float)0.,(float)0. };
    static real oazm[10] = { (float)0.,(float)0.,(float)0.,(float)0.,(float)
	    0.,(float)0.,(float)0.,(float)0.,(float)0.,(float)0. };
    static integer score = 0;
    static real maxd[9] = { (float)5.,(float)0.,(float)0.,(float)12.5,(float)
	    12.5,(float)12.5,(float)12.5,(float)12.5,(float)12.5 };
    static real value[9] = { (float)-200.,(float)300.,(float)300.,(float)0.,(
	    float)0.,(float)0.,(float)0.,(float)0.,(float)0. };
    static integer ship_r__ = 0;
    static real sa = (float)0.;
    static real ca = (float)1.;
    static real sp = (float)0.;
    static real cp = (float)1.;
    static real rox[10] = { (float)0.,(float)0.,(float)0.,(float)0.,(float)0.,
	    (float)0.,(float)0.,(float)0.,(float)0.,(float)0. };
    static real roy[10] = { (float)0.,(float)0.,(float)0.,(float)0.,(float)0.,
	    (float)0.,(float)0.,(float)0.,(float)0.,(float)0. };
    static real roz[10] = { (float)0.,(float)0.,(float)0.,(float)0.,(float)0.,
	    (float)0.,(float)0.,(float)0.,(float)0.,(float)0. };
    static logical scan = TRUE_;
    static logical tract = TRUE_;
    static logical phase = TRUE_;
    static integer ship_n__ = 0;
    static logical phase_d__ = FALSE_;
    static logical tract_ob__ = FALSE_;
    static integer scan_ob__ = 1;
    static integer tr_object__ = 0;
    static logical object[10] = { TRUE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
	    FALSE_,FALSE_,FALSE_,FALSE_ };
    static logical plot[10] = { FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,FALSE_,
	    FALSE_,FALSE_,FALSE_,FALSE_ };
    static logical lock_on__ = FALSE_;
    static logical refresh = TRUE_;
    static char dam_rating__[10*3+1] = "light     moderate  heavy     ";
    static char t_message__[80*3+1] = "Which should I lock onto captain?    \
                                           Input number of object to lock,  \
                                               any other input = No lock on \
                                                   ";
    static integer dock_n__ = 0;
    static char p_message__[80*3+1] = "Phaser control                       \
                                           Input number of object to lock ph\
asers on,                                      any other input = No phaser l\
ock on                                             ";
    static char e_message__[80*3+1] = "Photon Torpedo Trigger Radius Options\
                                           1 = 15  2 = 20  3 = 25  4 = 30  5\
 = 35  6 = 40                                  Enter option.                \
                                                   ";
    static char r_message__[80*3+1] = "Statistics for                       \
                                           Klingons  Romulans  Nemians  Nemi\
ans Docked  Score  Total                                                    \
                                                   ";
    static char a_message__[80*3+1] = "                                     \
                                                                            \
                                                                            \
                                                   ";
    static char b_message__[80*3+1] = "                                     \
                                                                            \
                                                                            \
                                                   ";
    static char k_message__[80*3+1] = "                                     \
                                                                            \
                                                                            \
                                                   ";
    static char ap_message__[80*3+1] = "Ship hit by enemy photon!           \
                                                                            \
                                                ";
    static char d_message__[80*6+1] = "                                     \
                                           Nemian freighter destroyed.      \
                                               Enemy spacecraft destroyed.  \
                                                   Second enemy spacecraft d\
estroyed.                                              Enemy photon torpedo \
destroyed.                                                 Photon torpedo de\
stroyed.                                                       ";
    static char l_message__[80*6+1] = "Navigation lock on star base.        \
                                           Navigation lock on Nemian freight\
er.                                            Navigation lock on enemy spac\
ecraft.                                            Navigation lock on second\
 enemy spacecraft.                                     ";
    static struct {
	char fill_1[80];
	char e_2[240];
	char fill_3[160];
	} equiv_183 = { {0}, {'N', 'e', 'm', 'i', 'a', 'n', ' ', 'f', 'r', 
		'e', 'i', 'g', 'h', 't', 'e', 'r', ' ', 'h', 'i', 't', ' ', 
		'b', 'y', ' ', 'p', 'h', 'o', 't', 'o', 'n', ' ', 't', 'o', 
		'r', 'p', 'e', 'd', 'o', '.', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'E', 
		'n', 'e', 'm', 'y', ' ', 's', 'h', 'i', 'p', ' ', 'h', 'i', 
		't', ' ', 'b', 'y', ' ', 'p', 'h', 'o', 't', 'o', 'n', ' ', 
		't', 'o', 'r', 'p', 'e', 'd', 'o', '.', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', 'E', 'n', 'e', 'm', 'y', 
		' ', 's', 'h', 'i', 'p', ' ', 'h', 'i', 't', ' ', 'b', 'y', 
		' ', 'p', 'h', 'o', 't', 'o', 'n', ' ', 't', 'o', 'r', 'p', 
		'e', 'd', 'o', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' '} };

#define ph_message__ ((char *)&equiv_183)

    static struct {
	char fill_1[80];
	char e_2[400];
	} equiv_184 = { {0}, {'N', 'e', 'm', 'i', 'a', 'n', ' ', 'f', 'r', 
		'e', 'i', 'g', 'h', 't', 'e', 'r', ' ', 'h', 'i', 't', ' ', 
		'b', 'y', ' ', 'p', 'h', 'a', 's', 'e', 'r', ' ', 'f', 'i', 
		'r', 'e', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'E', 
		'n', 'e', 'm', 'y', ' ', 's', 'h', 'i', 'p', ' ', 'h', 'i', 
		't', ' ', 'b', 'y', ' ', 'p', 'h', 'a', 's', 'e', 'r', ' ', 
		'f', 'i', 'r', 'e', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', 'E', 'n', 'e', 'm', 'y', 
		' ', 's', 'h', 'i', 'p', ' ', 'h', 'i', 't', ' ', 'b', 'y', 
		' ', 'p', 'h', 'a', 's', 'e', 'r', ' ', 'f', 'i', 'r', 'e', 
		'.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', 'E', 'n', 'e', 'm', 'y', ' ', 'P', 'h', 'o', 
		't', 'o', 'n', ' ', 't', 'o', 'r', 'p', 'e', 'd', 'o', ' ', 
		'h', 'i', 't', ' ', 'b', 'y', ' ', 'p', 'h', 'a', 's', 'e', 
		'r', ' ', 'f', 'i', 'r', 'e', '.', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'P', 
		'h', 'o', 't', 'o', 'n', ' ', 't', 'o', 'r', 'p', 'e', 'd', 
		'o', ' ', 'h', 'i', 't', ' ', 'b', 'y', ' ', 'p', 'h', 'a', 
		's', 'e', 'r', ' ', 'f', 'i', 'r', 'e', '.', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' '} };

#define ps_message__ ((char *)&equiv_184)

    static struct {
	char fill_1[80];
	char e_2[80];
	char fill_3[160];
	char e_4[1040];
	} equiv_185 = { {0}, {'T', 'r', 'a', 'c', 't', 'o', 'r', ' ', 'b', 
		'e', 'a', 'm', ' ', 'o', 'n', ' ', 'N', 'e', 'm', 'i', 'a', 
		'n', ' ', 'f', 'r', 'e', 'i', 'g', 'h', 't', 'e', 'r', ' ', 
		'd', 'r', 'o', 'p', 'p', 'e', 'd', '.', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, {0}, {
		'T', 'r', 'a', 'c', 't', 'o', 'r', ' ', 'b', 'e', 'a', 'm', 
		' ', 'o', 'n', ' ', 'e', 'n', 'e', 'm', 'y', ' ', 'p', 'h', 
		'o', 't', 'o', 'n', ' ', 'd', 'r', 'o', 'p', 'p', 'e', 'd', 
		'.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'T', 'r', 'a', 'c', 
		't', 'o', 'r', ' ', 'b', 'e', 'a', 'm', ' ', 'o', 'n', ' ', 
		'p', 'h', 'o', 't', 'o', 'n', ' ', 't', 'o', 'r', 'p', 'e', 
		'd', 'o', ' ', 'd', 'r', 'o', 'p', 'p', 'e', 'd', '.', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', 'T', 'r', 'a', 'c', 't', 'o', 'r', ' ', 
		'b', 'e', 'a', 'm', ' ', 'l', 'o', 'c', 'k', ' ', 'o', 'n', 
		' ', 'd', 'r', 'o', 'p', 'p', 'e', 'd', '.', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		'P', 'h', 'o', 't', 'o', 'n', ' ', 't', 'o', 'r', 'p', 'e', 
		'd', 'o', ' ', 'l', 'a', 'u', 'n', 'c', 'h', 'e', 'd', ' ', 
		's', 'i', 'r', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'I', '\'', 'm', ' ', 
		'g', 'i', 'v', 'i', 'n', 'g', ' ', 'i', 't', ' ', 'a', 'l', 
		'l', ' ', 's', 'h', 'e', '\'', 's', ' ', 'g', 'o', 't', ' ', 
		'c', 'a', 'p', 't', 'a', 'i', 'n', '.', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', 'S', 'c', 'a', 'n', 'n', 'e', 'r', ' ', 
		'l', 'o', 'c', 'k', ' ', 'o', 'n', ' ', 'l', 'o', 's', 't', 
		'.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		'N', 'e', 'm', 'i', 'a', 'n', ' ', 'f', 'r', 'e', 'i', 'g', 
		'h', 't', 'e', 'r', ' ', 'd', 'o', 'c', 'k', 'e', 'd', ' ', 
		'a', 't', ' ', 's', 't', 'a', 'r', ' ', 'b', 'a', 's', 'e', 
		'.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'S', 'c', 'o', 'r', 
		'e', ' ', 'f', 'o', 'r', ' ', 'd', 'e', 's', 't', 'r', 'o', 
		'y', 'i', 'n', 'g', ' ', 's', 'h', 'i', 'p', ':', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', 'G', 'o', 'o', 'd', ' ', 'g', 'o', 'i', 
		'n', 'g', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		'S', 'c', 'a', 'n', 'n', 'e', 'r', 's', ' ', 'r', 'e', 'p', 
		'o', 'r', 't', ' ', 't', 'h', 'a', 't', ' ', 't', 'h', 'e', 
		' ', 'd', 'a', 'm', 'a', 'g', 'e', ' ', 'w', 'a', 's', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'R', 'e', 'p', 'a', 
		'i', 'r', ' ', 'p', 'a', 'r', 't', 'i', 'e', 's', ' ', 'r', 
		'e', 'p', 'o', 'r', 't', ' ', 't', 'h', 'a', 't', ' ', 't', 
		'h', 'e', ' ', 'd', 'a', 'm', 'a', 'g', 'e', ' ', 'w', 'a', 
		's', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', 'P', 'o', 'i', 'n', 't', 's', ' ', 'l', 
		'o', 's', 't', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		'I', 't', '\'', 's', ' ', 'y', 'o', 'u', 'r', ' ', 'j', 'o', 
		'b', ' ', 't', 'o', ' ', 'd', 'e', 'f', 'e', 'n', 'd', ' ', 
		't', 'h', 'e', ' ', 'N', 'e', 'm', 'i', 'a', 'n', 's', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '} };

#define s_message__ ((char *)&equiv_185)

    static char sc_message__[80*6+1] = "Scanner locked on starbase.         \
                                            Scanner locked on Nemian freight\
er.                                             Scanner locked on enemy ship\
.                                                   Scanner locked on second\
 enemy ship.                                            Scanner locked on en\
emy photon.                                                 Scanner locked o\
n photon torpedo.                                               ";
    static struct {
	char fill_1[80];
	char e_2[80];
	char fill_3[160];
	char e_4[160];
	} equiv_186 = { {0}, {'N', 'e', 'm', 'i', 'a', 'n', ' ', 'f', 'r', 
		'e', 'i', 'g', 'h', 't', 'e', 'r', ' ', 'i', 'n', ' ', 't', 
		'r', 'a', 'c', 't', 'o', 'r', ' ', 'b', 'e', 'a', 'm', '.', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, {0}, {
		'E', 'n', 'e', 'm', 'y', ' ', 'p', 'h', 'o', 't', 'o', 'n', 
		' ', 'i', 'n', ' ', 't', 'r', 'a', 'c', 't', 'o', 'r', ' ', 
		'b', 'e', 'a', 'm', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'P', 'h', 'o', 't', 
		'o', 'n', ' ', 't', 'o', 'r', 'p', 'e', 'd', 'o', ' ', 'i', 
		'n', ' ', 't', 'r', 'a', 'c', 't', 'o', 'r', ' ', 'b', 'e', 
		'a', 'm', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
		' ', ' ', ' ', ' '} };

#define u_message__ ((char *)&equiv_186)

    static char sl_message__[80*3+1] = "Game put on hold.                   \
                                            STREK will not start again until\
 another                                        key is hit.                 \
                                                    ";
    static integer waited = 0;
    static integer turns_wait__ = 0;

    /* System generated locals */
    integer i__1, i__2, i__3, i__4;
    real r__1, r__2, r__3;

    /* Builtin functions */
    /* Subroutine */ int s_copy();
    integer s_wsfi(), do_fio(), e_wsfi();
    double sqrt(), sin(), cos(), r_sign(), atan();
    integer s_rsfi(), e_rsfi();
    /* Subroutine */ int s_stop();
    integer i_nint();

    /* Local variables */
    extern /* Subroutine */ int strek_assess_damage__(), 
	    strek_photon_damage__(), strek_no_energy__();
    static real seed;
    extern /* Subroutine */ int rand_();
    static integer rate;
    extern /* Subroutine */ int gprsetdrawvalue_();
    static integer item, l_object__;
    static real dist;
    static char key_file__[256];
    static real distance[30]	/* was [3][10] */, razm[3], tazm;
    static integer type, photon_c__[6];
    static doublereal turn;
    static logical new_ship__;
    extern /* Subroutine */ int strek_interpret_key__(), timewait_();
    static doublereal duration;
    extern /* Subroutine */ int strek_nemian__();
    static real timerelative;
    static integer i, j, k;
    static real check, brake[3], gprkeystroke;
    extern /* Subroutine */ int strek_move_enemy__();
    static shortint clock[3];
    static integer nav_c__;
    extern logical gprcondeventwait_();
    static shortint c_pos__[2];
    static char nick_name__[10], capt_name__[10];
    static integer ph_object__;
    static char t_key__[1];
    static shortint timer[3];
    static char ship_name__[30];
    static real pro_x__[10], pro_y__[10], trazm;
    static integer cum_score__;
    static char user_name__[10];
    static logical found, kling[3];
    extern /* Subroutine */ int timeclock_(), calfloatclock_();
    static real s1, s2, s3, t1, t2, t3, t4, ran_store__[10], t5, t6;
    extern /* Subroutine */ int strek_number_objects__(), strek_damage_info__(
	    );
    static integer num_times__;
    static real tempx, tempy, tempz;
    static shortint font_3__, font_4__;
    extern /* Subroutine */ int strek_message__();
    static integer pos_store__[20]	/* was [10][2] */;
    extern /* Subroutine */ int strek_scanner__(), strek_x_hairs__(), 
	    strek_place_enemy__(), strek_klingon__(), strek_phaser_fire__(), 
	    strek_screen_init__();
    static real dx, dy, dz, rangle[3];
    extern /* Subroutine */ int strek_startup__();
    static real tangle, orange[10], xt[10], yt[10];
    static shortint center[2];
    static integer trange;
    static real zt[10];
    extern /* Subroutine */ int strek_enemy_setup__(), strek_photon_1__(), 
	    strek_photon_2__(), strek_photon_3__(), strek_photon_4__(), 
	    strek_photon_5__(), strek_photon_6__(), strek_dock__();
    static integer option;
    static real trdist;
    static integer last_score__, status;
    extern /* Subroutine */ int strek_find_free_ob__();
    static logical unobscured;
    static real xt1, yt1, zt1;
    extern /* Subroutine */ int strek_place_nemian__();
    static shortint event_type__;
    static real gprnoevent;
    extern /* Subroutine */ int strek_starbase__(), gprenableinput_(), 
	    strek_flashers__();
    static real coa[9];
    extern /* Subroutine */ int strek_update_panel__();
    static logical agr[3];
    static integer phase_c__;
    static real soa[9], cop[9];
    static char key[1];
    static doublereal elapsed;
    static integer txc, tyc, tzc;
    static real sop[9];
    extern /* Subroutine */ int strek_draw_phasers__();
    static integer bitmap_desc__;
    static real trangle, trx, try_, trz;
    static logical two;
    extern /* Subroutine */ int strek_romulan_1__(), strek_romulan_2__();
    static logical reverse;
    extern /* Subroutine */ int calgetlocaltime_();
    static integer num_forward__;

    /* Fortran I/O blocks */
    static icilist io___99 = { 0, a_message__+160, 0, "(a36,a10)", 80, 1 };
    static icilist io___100 = { 0, ap_message__+160, 0, "(a42,a10)", 80, 1 };
    static icilist io___111 = { 0, k_message__+80, 0, "(a27,f10.2)", 80, 1 };
    static icilist io___112 = { 0, k_message__+160, 0, "(a11,a10)", 80, 1 };
    static icilist io___113 = { 0, k_message__+80, 0, "(a13,f10.2)", 80, 1 };
    static icilist io___114 = { 0, k_message__+160, 0, "(a36,a10)", 80, 1 };
    static icilist io___150 = { 0, t_key__, 0, "(i1)", 1, 1 };
    static icilist io___153 = { 0, t_key__, 0, "(i1)", 1, 1 };
    static icilist io___155 = { 0, a_message__+160, 0, "(a36,a10)", 80, 1 };
    static icilist io___156 = { 0, t_key__, 0, "(i1)", 1, 1 };
    static icilist io___158 = { 0, key, 0, "(i1)", 1, 1 };
    static icilist io___160 = { 0, t_key__, 0, "(i1)", 1, 1 };
    static icilist io___161 = { 0, r_message__, 0, "(a15,a30)", 80, 1 };
    static icilist io___162 = { 0, r_message__+160, 0, "(i8,i10,i9,i16,2i7)", 
	    80, 1 };



/*    ******************************************************************* 
*/
/*    *****                                                         ***** 
*/
/*    *****                STAR TREK VERSION 3.0                    ***** 
*/
/*    *****                                                         ***** 
*/
/*    *****                     written by                          ***** 
*/
/*    *****                                                         ***** 
*/
/*    *****                Justin S. Revenaugh                      ***** 
*/
/*    *****                                                         ***** 
*/
/*    *****                       7/87                              ***** 
*/
/*    *****                                                         ***** 
*/
/*    *****        Massachussetts Institute of Technology           ***** 
*/
/*    *****  Department of Earth, Atmospheric and Planetary Science ***** 
*/
/*    *****                                                         ***** 
*/
/*    ******************************************************************* 
*/

/*    STREK_MAIN is the main calling code for the STREK system. */
/*    It handles the database startup calls, graphics init call, */
/*    the screen update - resolve - key request sequence. */
/*    When the ship docks or dies it updates the database. */

/*    version 2.0 */

/* % include '/sys/ins/base.ins.ftn' */
/* % include '/sys/ins/gpr.ins.ftn' */
/* % include '/sys/ins/smdu.ins.ftn' */
/* % include '/sys/ins/time.ins.ftn' */
/* % include '/sys/ins/cal.ins.ftn' */

/*    STREK declarations */


/*   real variables (all ship position data) */


/*    message strings */


/*    logical toggles for objects */


/*    key interpretation common */


/*    data for STREK */


/*    statement functions for converting angles to rads */
/*    and vice-versa */


/*    call STREK_STARTUP to init db and get ship info */

    strek_startup__(user_name__, capt_name__, nick_name__, ship_name__, &
	    last_score__, &cum_score__, key_file__, &new_ship__, 10L, 10L, 
	    10L, 30L, 256L);

/*    call STREK_SCREEN_INIT */

    strek_screen_init__(&bitmap_desc__, &font_3__, &font_4__);

/*    enable keystroke events */

    gprenableinput_(&gprkeystroke, key_set__, &status);

/*    startup info panels (4 passes to init everything) */

    for (j = 1; j <= 4; ++j) {
	i__1 = (integer) energy;
	i__2 = (integer) xc;
	i__3 = (integer) yc;
	i__4 = (integer) zc;
	strek_update_panel__(&c__0, &i__1, &photons, &phase, &tract_ob__, &
		i__2, &i__3, &i__4, &scan, &c__0, &c__0, &c__0, &c__0, &
		scan_ob__);
/* L5: */
    }

/*    give an introductory message */

    s_copy(b_message__ + 80, "Welcome aboard sir, the bridge is all yours!", 
	    80L, 44L);
    strek_message__(b_message__, &c__3, 80L);

/*    call clock to get a random number seed */

    calgetlocaltime_(clock);
    seed = (r__1 = clock[2] / (float)3.3e4, dabs(r__1));

/*    start turn timer */

    timeclock_(timer);
    calfloatclock_(timer, &elapsed);

/*    get a nemian */

    strek_place_nemian__(&xc, &yc, &zc, &obx[1], &oby[1], &obz[1], &oazm[1], &
	    oangle[1], &ospeed[1], &seed);
    object[1] = TRUE_;
    odamage[1] = (float)0.;

/*    begin event driver loop */

L10:

/*    check phaser availability */

    if (! phase && phase_d__) {
	++phase_c__;
	if (phase_c__ > 40) {
	    phase_d__ = FALSE_;
	    phase = TRUE_;
	}
    }

/*    if nemian is getting too far away then refresh him */

    if (orange[1] > (float)9e6) {
	object[1] = FALSE_;
    }

/*    if there's no nemian then get one */

    if (! object[1]) {
	strek_place_nemian__(&xc, &yc, &zc, &obx[1], &oby[1], &obz[1], &oazm[
		1], &oangle[1], &ospeed[1], &seed);
	object[1] = TRUE_;
	odamage[1] = (float)0.;

/*    check for nemian docking */

    } else if (tr_object__ == 1 && tract_ob__) {
	if (distance[0] < (float)900. && dabs(speed) <= (float)1.) {
	    score += 500;
	    s_copy(b_message__ + 80, s_message__ + 800, 80L, 80L);
	    strek_message__(b_message__, &c__3, 80L);
	    tract_ob__ = FALSE_;
	    object[1] = FALSE_;
	    ++dock_n__;
	}
    }

/*    check for photon proximity explosions */

    for (j = 4; j <= 9; ++j) {
	if (object[j]) {
	    ++photon_c__[j - 4];
	    if (photon_c__[j - 4] > 60) {
		object[j] = FALSE_;
	    }
	    if (j > 6) {
		for (i = 1; i <= 3; ++i) {
		    if (object[i] && (distance[i + j * 3 - 1] <= photon_tr__[
			    j - 4] && orange[j] > (float)1600.)) {
			object[j] = FALSE_;
			strek_photon_damage__(&distance[i + j * 3 - 1], &
				odamage[i], &seed, &type);
			s_copy(a_message__, ph_message__ + (index[i] - 1) * 
				80, 80L, 80L);
			s_wsfi(&io___99);
			do_fio(&c__1, s_message__ + 1040, 80L);
			do_fio(&c__1, dam_rating__ + (type - 1) * 10, 10L);
			e_wsfi();
			strek_message__(a_message__, &c__3, 80L);
		    }
/* L30: */
		}
	    } else {

/*    check for nemian hits */

		if (object[1] && distance[j * 3] < photon_tr__[j - 4]) {
		    if (! object[2] || distance[j * 3 + 1] > (float)900.) {
			if (! object[3] || distance[j * 3 + 2] > (float)900.) 
				{
			    object[j] = FALSE_;
			    strek_photon_damage__(&distance[j * 3], &odamage[
				    1], &seed, &type);
			}
		    }
		}

/*    check for player ship hits */

		if (orange[j] < photon_tr__[j - 4]) {
		    if (! object[2] || distance[j * 3 + 1] > (float)225.) {
			if (! object[3] || distance[j * 3 + 2] > (float)225.) 
				{
			    object[j] = FALSE_;
			    strek_photon_damage__(&orange[j], &damage, &seed, 
				    &type);
			    s_wsfi(&io___100);
			    do_fio(&c__1, s_message__ + 1120, 80L);
			    do_fio(&c__1, dam_rating__ + (type - 1) * 10, 10L)
				    ;
			    e_wsfi();
			    strek_message__(ap_message__, &c__3, 80L);
			}
		    }
		}
	    }
	}
/* L20: */
    }

/*    if enemy ships are alive then move 'em */

    if (object[2] || object[3]) {
	for (j = 2; j <= 3; ++j) {
	    if (object[j]) {
		strek_move_enemy__(&j, obx, oby, obz, oazm, oangle, ospeed, &
			xc, &yc, &zc, &azm, &angle, &speed, &agr[j - 1], 
			object, &rox[j], &roy[j], &roz[j], odamage, &pc[j - 1]
			, distance, &kling[j - 1], &cm[j - 1], &cs[j - 1], 
			orange, &razm[j - 1], &rangle[j - 1], &brake[j - 1], &
			damage, photon_c__, &phase_c__, pro_x__, pro_y__, &
			seed, center);
	    }
/* L50: */
	}
    } else if (waited > turns_wait__) {

/*    reset damage totals, pick ship type and aggression levels */

	strek_enemy_setup__(odamage, agr, kling, maxd, object, &seed, &two, 
		pc);
	j = 2;
	k = 3;
	if (two) {
	    strek_place_enemy__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &
		    oazm[j], &oangle[j], &ospeed[j], &seed);
	    strek_place_enemy__(&xc, &yc, &zc, &obx[k], &oby[k], &obz[k], &
		    oazm[k], &oangle[k], &ospeed[k], &seed);
	} else {
	    strek_place_enemy__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &
		    oazm[j], &oangle[j], &ospeed[j], &seed);
	}
	waited = 0;
    } else if (waited == 0) {
	rand_(&seed);
	turns_wait__ = seed * (float)150. + 50;
	waited = 1;
    } else {
	++waited;
    }

/*    evaluate sum of damages (both photon and phaser) to other objects */


    for (j = 1; j <= 9; ++j) {
	if (object[j] && odamage[j] >= maxd[j - 1]) {
	    if (j == 1) {
		++ship_n__;
	    } else if (kling[j - 1]) {
		++ship_k__;
	    } else {
		++ship_r__;
	    }
	    object[j] = FALSE_;
	    s_copy(k_message__, d_message__ + (index[j] - 1) * 80, 80L, 80L);
	    if (j == 2 || j == 3) {
		s_wsfi(&io___111);
		do_fio(&c__1, s_message__ + 880, 80L);
		do_fio(&c__1, (char *)&value[j - 1], (ftnlen)sizeof(real));
		e_wsfi();
		s_wsfi(&io___112);
		do_fio(&c__1, s_message__ + 960, 80L);
		do_fio(&c__1, nick_name__, 10L);
		e_wsfi();
	    } else if (j == 1) {
		s_wsfi(&io___113);
		do_fio(&c__1, s_message__ + 1200, 80L);
		do_fio(&c__1, (char *)&value[j - 1], (ftnlen)sizeof(real));
		e_wsfi();
		s_wsfi(&io___114);
		do_fio(&c__1, s_message__ + 1280, 80L);
		do_fio(&c__1, capt_name__, 10L);
		e_wsfi();
		rand_(&seed);
		if (seed > (float).5) {
		    agr[1] = FALSE_;
		}
		rand_(&seed);
		if (seed > (float).5) {
		    agr[2] = FALSE_;
		}
	    } else {
		s_copy(k_message__ + 80, k_message__, 80L, 80L);
		s_copy(k_message__, " ", 80L, 1L);
		s_copy(k_message__ + 160, " ", 80L, 1L);
	    }
	    strek_message__(k_message__, &c__3, 80L);
	    score += value[j - 1];
	}
/* L40: */
    }

/*    process lock on coordinates */

    ++nav_c__;
    if (lock_on__) {
	if (orange[l_object__] > (float)1e4 && nav_c__ >= 10) {
	    nav_c__ = 0;
	    if (speed < (float)0.) {
		s1 = -(doublereal)speed;
		s2 = azm + (float)180.;
		if (s2 > (float)360.) {
		    s2 += (float)-360.;
		}
		s3 = (float)360. - angle;
		reverse = TRUE_;
	    } else {
		s1 = speed;
		s2 = azm;
		s3 = angle;
		reverse = FALSE_;
	    }
	    if (s1 > (float).01) {
		num_forward__ = sqrt(orange[l_object__]) / s1;
	    } else {
		num_forward__ = 20;
	    }
	    j = l_object__;
	    xt1 = -num_forward__ * ospeed[j] * sin(oazm[j]) * cos(oangle[j]) 
		    + obx[j];
	    yt1 = num_forward__ * ospeed[j] * cos(oazm[j]) * cos(oangle[j]) + 
		    oby[j];
	    zt1 = num_forward__ * ospeed[j] * sin(oangle[j]) + obz[j];
	    dx = xt1 - xc;
	    dy = yt1 - yc;
	    dz = zt1 - zc;
	    if (dabs(dy) < (float)1.) {
		dy = r_sign(&c_b38, &dy);
	    }
	    if (dy <= (float)0.) {
		r__1 = atan(dx / dy);
		tazm = -(doublereal)(r__1 * (float)180. / (float)3.141592653) 
			+ (float)180.;
	    } else {
		r__1 = atan(dx / dy);
		tazm = -(doublereal)(r__1 * (float)180. / (float)3.141592653);

	    }
	    if (tazm < (float)0.) {
		tazm += (float)360.;
	    }
/* Computing 2nd power */
	    r__1 = dx;
/* Computing 2nd power */
	    r__2 = dy;
	    dist = sqrt(r__1 * r__1 + r__2 * r__2);
	    if (dist < (float)1.) {
		dist = (float)1.;
	    }
	    r__1 = atan(dz / dist);
	    tangle = r__1 * (float)180. / (float)3.141592653;

/*    pick smallest angle (needed due to arctan being only in */
/*    I and IV quadrants */

	    t1 = (tazm - s2) / (float)10.;
	    t2 = (tangle - s3) / (float)10.;
	    t3 = (tazm - (s2 + (float)360.)) / (float)10.;
	    t4 = (tangle - (s3 + (float)360.)) / (float)10.;
	    t5 = (tazm - (s2 - (float)360.)) / (float)10.;
	    t6 = (tangle - (s3 - (float)360.)) / (float)10.;
	    if (dabs(t3) < dabs(t1)) {
		t1 = t3;
	    }
	    if (dabs(t5) < dabs(t1)) {
		t1 = t5;
	    }
	    if (dabs(t4) < dabs(t2)) {
		t2 = t4;
	    }
	    if (dabs(t6) < dabs(t2)) {
		t2 = t6;
	    }
	    if (reverse) {
		t2 = -(doublereal)t2;
	    }

/*    limit rotation angles by max ship ability */

	    if (dabs(t1) > (float).6) {
		t1 = r_sign(&c_b39, &t1);
	    }
	    if (dabs(t2) > (float).6) {
		t2 = r_sign(&c_b39, &t2);
	    }

/*    set rotation vars */

	    rot_azm__[9] = t1;
	    rot_ang__[9] = t2;
	}
    }

/*    if rotate then rotate */

    if (rot_azm__[r_index__ - 1] != (float)0.) {
	azm += rot_azm__[r_index__ - 1];
	sa = sin(azm * (float)3.141592653 / (float)180.);
	ca = cos(azm * (float)3.141592653 / (float)180.);
    }
    if (rot_ang__[r_index__ - 1] != (float)0.) {
	angle += rot_ang__[r_index__ - 1];
	sp = sin(angle * (float)3.141592653 / (float)180.);
	cp = cos(angle * (float)3.141592653 / (float)180.);
    }
    if (! rotate && ! lock_on__) {
	r_index__ = 9;
    }

/*    rotate tractored object back to translated galatic coords centered 
*/
/*    on ship */

    if (tract_ob__ && tract) {
	if (! object[tr_object__]) {
	    tract_ob__ = FALSE_;
	    s_copy(b_message__ + 80, s_message__ + (index[tr_object__] - 1) * 
		    80, 80L, 80L);
	    strek_message__(b_message__, &c__3, 80L);
	} else {
	    trazm += rot_azm__[r_index__ - 1] * (float)3.141592653 / (float)
		    180.;
	    t1 = cos(trazm - azm * (float)3.141592653 / (float)180.);
	    trangle += rot_ang__[r_index__ - 1] * (float)3.141592653 / (float)
		    180. * t1;
	    j = tr_object__;
	    trx = rox[j] * ca - roy[j] * sa * cp + roz[j] * sa * sp + xc;
	    try_ = rox[j] * sa + roy[j] * ca * cp - roz[j] * ca * sp + yc;
	    trz = roy[j] * sp + roz[j] * cp + zc;
	}
    }

/*    check that scan object still exists */

    if (! object[scan_ob__] && scan_ob__ >= 4) {
	scan_ob__ = 1;
	s_copy(b_message__ + 80, s_message__ + 720, 80L, 80L);
	strek_message__(b_message__, &c__3, 80L);
    }

/*    check that nav lock on object still exists */

    if (lock_on__ && (! object[l_object__] || orange[l_object__] < (float)1e4 
	    || ! scan)) {
	lock_on__ = FALSE_;
	s_copy(b_message__ + 80, "Navigation lock on lost.", 80L, 24L);
	strek_message__(b_message__, &c__3, 80L);
	r_index__ = 9;
    }

/*    apply damage to the player's ship */

    strek_assess_damage__(d_pct__, &damage, &scan, &tract, &phase, &energy, &
	    seed);

/*    get a key if one has been struck */

    unobscured = gprcondeventwait_(&event_type__, key, c_pos__, &status, 1L);
    if ((real) event_type__ != gprnoevent) {
	strek_interpret_key__(key, 1L);

/*    process a speed key */

	if (*key == 'a') {
	    speed += (float).5;
	    if (speed > (float)5.) {
		speed = (float)5.;
		s_copy(b_message__ + 80, s_message__ + 640, 80L, 80L);
		strek_message__(b_message__, &c__3, 80L);
	    }
	} else if (*key == 's') {
	    speed += (float)-.5;
	    if (speed < (float)-5.) {
		speed = (float)-5.;
		s_copy(b_message__ + 80, s_message__ + 640, 80L, 80L);
		strek_message__(b_message__, &c__3, 80L);
	    }
	}

/*    process a rotate key */

	if (! lock_on__) {
	    if (*key == 'm') {
		r_index__ = 9;
	    } else if (*key == 'b') {
		rotate = ! rotate;
	    } else {
		if (! rotate) {
		    if (*key == 'u') {
			r_index__ = 1;
		    } else if (*key == 'j') {
			r_index__ = 2;
		    } else if (*key == 'h') {
			r_index__ = 3;
		    } else if (*key == 'n') {
			r_index__ = 4;
		    }
		} else {
		    if (*key == 'u') {
			r_index__ = 5;
		    } else if (*key == 'j') {
			r_index__ = 6;
		    } else if (*key == 'h') {
			r_index__ = 7;
		    } else if (*key == 'n') {
			r_index__ = 8;
		    }
		}
	    }
	}

/*    process a tractor beam key */

	if (*key == 't' && tract && ! tract_ob__) {
	    strek_number_objects__(pos_store__, ran_store__, object, &c__1);
	    strek_message__(t_message__, &c__3, 80L);
	    i = 0;
L60:
	    ++i;
	    unobscured = gprcondeventwait_(&event_type__, t_key__, c_pos__, &
		    status, 1L);
	    if ((real) event_type__ != gprnoevent || i > 3000) {
		goto L70;
	    }
	    goto L60;
L70:
	    strek_number_objects__(pos_store__, ran_store__, object, &c__0);
	    if ((real) event_type__ != gprnoevent) {
		strek_interpret_key__(t_key__, 1L);
		if (*t_key__ == '1' || *t_key__ >= '4' && *t_key__ <= '9') {
		    s_rsfi(&io___150);
		    do_fio(&c__1, (char *)&tr_object__, (ftnlen)sizeof(
			    integer));
		    e_rsfi();
		    if (object[tr_object__] && orange[tr_object__] < (float)
			    9e4) {
			tract_ob__ = TRUE_;
			j = tr_object__;
			trx = obx[j];
			try_ = oby[j];
			trz = obz[j];
			trazm = oazm[j];
			trangle = oangle[j];
			trdist = orange[j];
			s_copy(b_message__ + 80, u_message__ + (index[j] - 1) 
				* 80, 80L, 80L);
			strek_message__(b_message__, &c__3, 80L);
		    }
		}
	    }
	}

/*    process a drop tractor key */

	if (*key == 'r' && tract_ob__) {
	    tract_ob__ = FALSE_;
	    oazm[tr_object__] = trazm;
	    oangle[tr_object__] = trangle;
	    s_copy(b_message__ + 80, s_message__ + 480, 80L, 80L);
	    strek_message__(b_message__, &c__3, 80L);
	}

/*    process an damage information key */

	if (*key == 'i') {
	    strek_damage_info__(d_pct__, capt_name__, nick_name__, 10L, 10L);
	}

/*    process a photon key */

	if (*key == 'f' && photons >= 1) {
	    strek_find_free_ob__(object, &c__7, &j, &found);
	    if (found) {
		object[j] = TRUE_;
		photon_c__[j - 4] = 0;
		--photons;
		obx[j] = xc;
		oby[j] = yc;
		obz[j] = zc;
		oazm[j] = azm * (float)3.141592653 / (float)180.;
		oangle[j] = angle * (float)3.141592653 / (float)180.;
		ospeed[j] = (float)10.;
		s_copy(b_message__ + 80, s_message__ + 560, 80L, 80L);
		strek_message__(b_message__, &c__3, 80L);
	    }
	}

/*    process a phaser key */

	if (*key == 'p' && phase && energy > (float)30.) {
	    strek_number_objects__(pos_store__, ran_store__, object, &c__1);
	    strek_message__(p_message__, &c__3, 80L);
	    i = 0;
L80:
	    ++i;
	    unobscured = gprcondeventwait_(&event_type__, t_key__, c_pos__, &
		    status, 1L);
	    if ((real) event_type__ != gprnoevent || i > 3000) {
		goto L90;
	    }
	    goto L80;
L90:
	    strek_number_objects__(pos_store__, ran_store__, object, &c__0);
	    if ((real) event_type__ != gprnoevent) {
		strek_interpret_key__(t_key__, 1L);
		if (*t_key__ >= '0' && *t_key__ <= '9') {
		    s_rsfi(&io___153);
		    do_fio(&c__1, (char *)&ph_object__, (ftnlen)sizeof(
			    integer));
		    e_rsfi();
		    if (object[ph_object__] && orange[ph_object__] < (float)
			    2.5e5) {
			if (pro_x__[ph_object__] <= (float)800. && pro_x__[
				ph_object__] >= (float)100. && (pro_y__[
				ph_object__] <= (float)700. && pro_y__[
				ph_object__] >= (float)100.)) {
			    i__1 = (integer) pro_x__[ph_object__];
			    i__2 = (integer) pro_y__[ph_object__];
			    strek_draw_phasers__(&i__1, &i__2);
			    energy += (float)-30.;
			    phase_d__ = TRUE_;
			    phase_c__ = 0;
			    phase = FALSE_;

/*    do damage to other ship */

			    strek_phaser_fire__(&orange[ph_object__], &seed, &
				    odamage[ph_object__], &type);
			    s_copy(a_message__, ps_message__ + (index[
				    ph_object__] - 1) * 80, 80L, 80L);
			    s_wsfi(&io___155);
			    do_fio(&c__1, s_message__ + 1040, 80L);
			    do_fio(&c__1, dam_rating__ + (type - 1) * 10, 10L)
				    ;
			    e_wsfi();
			    strek_message__(a_message__, &c__3, 80L);
			}
		    }
		}
	    }
	}

/*    process a explode radius key */

	if (*key == 'e') {
	    strek_message__(e_message__, &c__3, 80L);
	    i = 0;
L100:
	    ++i;
	    unobscured = gprcondeventwait_(&event_type__, t_key__, c_pos__, &
		    status, 1L);
	    if ((real) event_type__ != gprnoevent || i > 5000) {
		goto L110;
	    }
	    goto L100;
L110:
	    if ((real) event_type__ != gprnoevent) {
		strek_interpret_key__(t_key__, 1L);
		if (*t_key__ > '0' && *t_key__ <= '6') {
		    s_rsfi(&io___156);
		    do_fio(&c__1, (char *)&option, (ftnlen)sizeof(integer));
		    e_rsfi();
		    t1 = option * (float)5. + (float)10.;
/* Computing 2nd power */
		    r__1 = t1;
		    photon_tr__[3] = r__1 * r__1;
		    photon_tr__[4] = photon_tr__[3];
		    photon_tr__[5] = photon_tr__[3];
		}
	    }
	}

/*    change scanner object keys */

	if (*key >= '0' && *key <= '9') {
	    s_rsfi(&io___158);
	    do_fio(&c__1, (char *)&item, (ftnlen)sizeof(integer));
	    e_rsfi();
	    if (object[item]) {
		scan_ob__ = item;
		s_copy(b_message__ + 80, sc_message__ + (index[item] - 1) * 
			80, 80L, 80L);
		strek_message__(b_message__, &c__3, 80L);
	    }
	}

/*    process a nav lock on key */

	if (*key == 'l' && scan) {
	    strek_message__(t_message__, &c__3, 80L);
	    i = 0;
L120:
	    ++i;
	    unobscured = gprcondeventwait_(&event_type__, t_key__, c_pos__, &
		    status, 1L);
	    if ((real) event_type__ != gprnoevent || i > 5000) {
		goto L130;
	    }
	    goto L120;
L130:
	    if ((real) event_type__ != gprnoevent) {
		strek_interpret_key__(t_key__, 1L);
		if (*t_key__ >= '0' && *t_key__ <= '3') {
		    s_rsfi(&io___160);
		    do_fio(&c__1, (char *)&l_object__, (ftnlen)sizeof(integer)
			    );
		    e_rsfi();
		    if (object[l_object__] && orange[l_object__] > (float)
			    22500.) {
			lock_on__ = TRUE_;
			s_copy(b_message__ + 80, l_message__ + (index[
				l_object__] - 1) * 80, 80L, 80L);
			strek_message__(b_message__, &c__3, 80L);
			r_index__ = 10;
			nav_c__ = 10;
		    }
		}
	    }
	}

/*    process a nav lock drop key */

	if (*key == 'o' && lock_on__) {
	    lock_on__ = FALSE_;
	    s_copy(b_message__ + 80, "Navigation lock on dropped.", 80L, 27L);

	    strek_message__(b_message__, &c__3, 80L);
	    r_index__ = 9;
	}

/*    process a dock key */

	if (*key == 'd' && orange[0] < (float)900. && dabs(speed) < (float)1.)
		 {
	    strek_dock__(d_pct__, &score, user_name__, capt_name__, 
		    nick_name__, ship_name__, &cum_score__, key_file__, &
		    new_ship__, 10L, 10L, 10L, 30L, 256L);
	    s_stop("", 0L);
	}

/*    process a current score key */

	if (*key == 'c') {
	    s_wsfi(&io___161);
	    do_fio(&c__1, r_message__, 80L);
	    do_fio(&c__1, ship_name__, 30L);
	    e_wsfi();
	    s_wsfi(&io___162);
	    do_fio(&c__1, (char *)&ship_k__, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&ship_r__, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&ship_n__, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&dock_n__, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&score, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&cum_score__, (ftnlen)sizeof(integer));
	    e_wsfi();
	    strek_message__(r_message__, &c__3, 80L);
	}

/*    process a clear com window key */

	if (*key == 'z') {
	    s_copy(b_message__ + 80, " ", 80L, 1L);
	    strek_message__(b_message__, &c__3, 80L);
	}

/*    process a sleep until key */

	if (*key == '/') {
	    strek_message__(sl_message__, &c__3, 80L);
L125:
	    unobscured = gprcondeventwait_(&event_type__, t_key__, c_pos__, &
		    status, 1L);
	    if ((real) event_type__ != gprnoevent) {
		goto L135;
	    }
	    goto L125;
L135:
	    s_copy(b_message__ + 80, " ", 80L, 1L);
	    strek_message__(b_message__, &c__3, 80L);
	}

/*    end parsing routines */

    }

/*    put angles back to normal (between 0 and 360) */

    if (azm < (float)0.) {
	azm += (float)360.;
    }
    if (azm >= (float)360.) {
	azm += (float)-360.;
    }
    if (angle < (float)0.) {
	angle += (float)360.;
    }
    if (angle >= (float)360.) {
	angle += (float)-360.;
    }

/*     add engine energy output */

    energy += (d_pct__[0] + d_pct__[1]) * (float).35;

/*     subtract off energy due to speed and rotation */

    energy = energy - dabs(speed) / (float)7.5 - rot_cost__[r_index__ - 1];

/*     subtract energy due to tractors */

    if (tract_ob__) {
	energy = energy - sqrt(trdist) / (float)60. * tr_cost__[tr_object__] 
		+ (float).1;
    }

/*     limit energy by battery percent */

    check = d_pct__[3] * (float)1e3;
    if (energy > check) {
	energy = check;
    }

/*     if out of energy start (or continue) death march */

    if (energy < (float)0.) {
	++num_times__;
	strek_no_energy__(&num_times__, user_name__, capt_name__, nick_name__,
		 ship_name__, key_file__, &score, &cum_score__, &new_ship__, 
		10L, 10L, 10L, 30L, 256L);
    } else {
	num_times__ = 0;
    }

/*    process new coordinates */

    tempx = xc;
    tempy = yc;
    tempz = zc;
    xc = -(doublereal)sa * cp * speed + xc;
    yc = ca * cp * speed + yc;
    zc = sp * speed + zc;
    for (j = 0; j <= 9; ++j) {
	if (object[j]) {
	    if (j != 0) {
		soa[j - 1] = sin(oazm[j]);
		coa[j - 1] = cos(oazm[j]);
		sop[j - 1] = sin(oangle[j]);
		cop[j - 1] = cos(oangle[j]);
		obx[j] = -(doublereal)soa[j - 1] * cop[j - 1] * ospeed[j] + 
			obx[j];
		oby[j] = coa[j - 1] * cop[j - 1] * ospeed[j] + oby[j];
		obz[j] = sop[j - 1] * ospeed[j] + obz[j];
	    }
	    xt[j] = obx[j] - xc;
	    yt[j] = oby[j] - yc;
	    zt[j] = obz[j] - zc;
/* Computing 2nd power */
	    r__1 = xt[j];
/* Computing 2nd power */
	    r__2 = yt[j];
/* Computing 2nd power */
	    r__3 = zt[j];
	    orange[j] = r__1 * r__1 + r__2 * r__2 + r__3 * r__3;
	}
/* L150: */
    }

/*    update tractored object */

    if (tract_ob__ && tract) {
	trx = trx - tempx + xc;
	try_ = try_ - tempy + yc;
	trz = trz - tempz + zc;
	j = tr_object__;
	obx[j] = trx;
	oby[j] = try_;
	obz[j] = trz;
	oazm[j] = trazm;
	oangle[j] = trangle;
	xt[j] = obx[j] - xc;
	yt[j] = oby[j] - yc;
	zt[j] = obz[j] - zc;
/* Computing 2nd power */
	r__1 = xt[j];
/* Computing 2nd power */
	r__2 = yt[j];
/* Computing 2nd power */
	r__3 = zt[j];
	orange[j] = r__1 * r__1 + r__2 * r__2 + r__3 * r__3;
	trdist = orange[j];
    }

/*    get object to object distances when both exist */

    for (j = 0; j <= 9; ++j) {
	if (object[j]) {
	    for (i = 1; i <= 3; ++i) {
		if (object[i] && i != j) {
/* Computing 2nd power */
		    r__1 = obx[i] - obx[j];
/* Computing 2nd power */
		    r__2 = oby[i] - oby[j];
/* Computing 2nd power */
		    r__3 = obz[i] - obz[j];
		    distance[i + j * 3 - 1] = r__1 * r__1 + r__2 * r__2 + 
			    r__3 * r__3;
		}
/* L170: */
	    }
	}
/* L160: */
    }

/*    rotate objects into shipocentric coordinates */

    for (j = 0; j <= 9; ++j) {
	if (object[j]) {
	    rox[j] = xt[j] * ca + yt[j] * sa;
	    roy[j] = -(doublereal)xt[j] * sa * cp + yt[j] * ca * cp + zt[j] * 
		    sp;
	    roz[j] = xt[j] * sa * sp - yt[j] * ca * sp + zt[j] * cp;

/*    project shiopcentric coordinates to screen coords */

	    if (roy[j] > (float)1.) {
		pro_x__[j] = rox[j] / roy[j] * (float)350. + (float)450.;
		pro_y__[j] = (float)400. - roz[j] / roy[j] * (float)350.;
		if ((r__1 = pro_x__[j], dabs(r__1)) > (float)3e3) {
		    pro_x__[j] = (float)1e3;
		}
		if ((r__1 = pro_y__[j], dabs(r__1)) > (float)3e3) {
		    pro_y__[j] = (float)1e3;
		}
	    } else {
		pro_x__[j] = (float)1e3;
		pro_y__[j] = (float)1e3;
		if (j == 2) {
		    center[0] = 1000;
		    center[1] = 1000;
		}
	    }

/*    fill temporary array for use in scanner windows */

	    pos_store__[j] = pro_x__[j];
	    pos_store__[j + 10] = pro_y__[j];
	}
/* L180: */
    }

/*     erase old objects */

    gprsetdrawvalue_(&c__0, &status);
    if (refresh) {
	strek_scanner__(rox, roy, roz, object, &c__0);
    }
    if (plot[0]) {
	strek_starbase__(&xc, &yc, &zc, &ca, &cp, &sa, &sp, &c__0);
    }
    for (j = 1; j <= 9; ++j) {
	if (plot[j]) {
	    switch ((int)j) {
		case 1:  goto L191;
		case 2:  goto L192;
		case 3:  goto L193;
		case 4:  goto L194;
		case 5:  goto L195;
		case 6:  goto L196;
		case 7:  goto L197;
		case 8:  goto L198;
		case 9:  goto L199;
	    }
L191:
	    strek_nemian__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &ca, &sa,
		     &cp, &sp, &c__0, &soa[j - 1], &coa[j - 1], &sop[j - 1], &
		    cop[j - 1]);
	    goto L190;
L192:
	    if (kling[j - 1]) {
		strek_klingon__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &ca,
			 &sa, &cp, &sp, &c__0, center, &soa[j - 1], &coa[j - 
			1], &sop[j - 1], &cop[j - 1]);
	    } else {
		strek_romulan_1__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &
			ca, &sa, &cp, &sp, &c__0, &soa[j - 1], &coa[j - 1], &
			sop[j - 1], &cop[j - 1]);
	    }
	    goto L190;
L193:
	    strek_romulan_2__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &ca, &
		    sa, &cp, &sp, &c__0, &soa[j - 1], &coa[j - 1], &sop[j - 1]
		    , &cop[j - 1]);
	    goto L190;
L194:
	    strek_photon_1__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &ca, &
		    sa, &cp, &sp, &c__0);
	    goto L190;
L195:
	    strek_photon_2__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &ca, &
		    sa, &cp, &sp, &c__0);
	    goto L190;
L196:
	    strek_photon_3__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &ca, &
		    sa, &cp, &sp, &c__0);
	    goto L190;
L197:
	    strek_photon_4__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &ca, &
		    sa, &cp, &sp, &c__0);
	    goto L190;
L198:
	    strek_photon_5__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &ca, &
		    sa, &cp, &sp, &c__0);
	    goto L190;
L199:
	    strek_photon_6__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[j], &ca, &
		    sa, &cp, &sp, &c__0);
	    goto L190;
	}
L190:
	;
    }

/*    update screen objects */

    gprsetdrawvalue_(&c__1, &status);
    if (refresh) {
	strek_scanner__(rox, roy, roz, object, &c__1);
    }
    refresh = ! refresh;
    for (j = 0; j <= 9; ++j) {
	plot[j] = FALSE_;
	ran_store__[j] = orange[j];
	if (object[j] && orange[j] < (float)4e6) {
	    if (pro_x__[j] < (float)900. && pro_x__[j] > (float)0.) {
		if (pro_y__[j] < (float)800. && pro_y__[j] > (float)0.) {
		    plot[j] = TRUE_;
		    if (j == 0) {
			strek_starbase__(&xc, &yc, &zc, &ca, &cp, &sa, &sp, &
				c__1);
		    } else {
			switch ((int)j) {
			    case 1:  goto L201;
			    case 2:  goto L202;
			    case 3:  goto L203;
			    case 4:  goto L204;
			    case 5:  goto L205;
			    case 6:  goto L206;
			    case 7:  goto L207;
			    case 8:  goto L208;
			    case 9:  goto L209;
			}
L201:
			strek_nemian__(&xc, &yc, &zc, &obx[j], &oby[j], &obz[
				j], &ca, &sa, &cp, &sp, &c__1, &soa[j - 1], &
				coa[j - 1], &sop[j - 1], &cop[j - 1]);
			goto L200;
L202:
			if (kling[j - 1]) {
			    strek_klingon__(&xc, &yc, &zc, &obx[j], &oby[j], &
				    obz[j], &ca, &sa, &cp, &sp, &c__1, center,
				     &soa[j - 1], &coa[j - 1], &sop[j - 1], &
				    cop[j - 1]);
			} else {
			    strek_romulan_1__(&xc, &yc, &zc, &obx[j], &oby[j],
				     &obz[j], &ca, &sa, &cp, &sp, &c__1, &soa[
				    j - 1], &coa[j - 1], &sop[j - 1], &cop[j 
				    - 1]);
			}
			goto L200;
L203:
			strek_romulan_2__(&xc, &yc, &zc, &obx[j], &oby[j], &
				obz[j], &ca, &sa, &cp, &sp, &c__1, &soa[j - 1]
				, &coa[j - 1], &sop[j - 1], &cop[j - 1]);
			goto L200;
L204:
			strek_photon_1__(&xc, &yc, &zc, &obx[j], &oby[j], &
				obz[j], &ca, &sa, &cp, &sp, &c__1);
			goto L200;
L205:
			strek_photon_2__(&xc, &yc, &zc, &obx[j], &oby[j], &
				obz[j], &ca, &sa, &cp, &sp, &c__1);
			goto L200;
L206:
			strek_photon_3__(&xc, &yc, &zc, &obx[j], &oby[j], &
				obz[j], &ca, &sa, &cp, &sp, &c__1);
			goto L200;
L207:
			strek_photon_4__(&xc, &yc, &zc, &obx[j], &oby[j], &
				obz[j], &ca, &sa, &cp, &sp, &c__1);
			goto L200;
L208:
			strek_photon_5__(&xc, &yc, &zc, &obx[j], &oby[j], &
				obz[j], &ca, &sa, &cp, &sp, &c__1);
			goto L200;
L209:
			strek_photon_6__(&xc, &yc, &zc, &obx[j], &oby[j], &
				obz[j], &ca, &sa, &cp, &sp, &c__1);
			goto L200;
		    }
		}
	    }
	}
L200:
	;
    }

/*    draw center of the screen crosshairs */

    strek_x_hairs__();

/*    update panels */

    if (scan) {
	txc = i_nint(&rox[scan_ob__]);
	tyc = i_nint(&roy[scan_ob__]);
	tzc = i_nint(&roz[scan_ob__]);
	r__1 = sqrt(orange[scan_ob__]);
	trange = i_nint(&r__1);
    }
    rate = speed * 2;
    i__1 = (integer) energy;
    i__2 = (integer) xc;
    i__3 = (integer) yc;
    i__4 = (integer) zc;
    strek_update_panel__(&rate, &i__1, &photons, &phase, &tract_ob__, &i__2, &
	    i__3, &i__4, &scan, &txc, &tyc, &tzc, &trange, &scan_ob__);
    strek_flashers__(object, &lock_on__, &energy, &bitmap_desc__);

/*    evaluate the turn duration, if it is shorter than the */
/*    minimum (which is .06 seconds) then request it again. */
/*    Since this call is slow it makes an ideal timer. */

/* L210: */
    timeclock_(timer);
    calfloatclock_(timer, &turn);
    duration = turn - elapsed;
    if (duration > .06) {
	elapsed = turn;
/*        goto 10 */
    }
    timer[0] = 0;
    timer[1] = 0;
    timer[2] = 15000;
    timewait_(&timerelative, timer, &status);
    goto L10;
/*      goto 210 */
} /* MAIN__ */

#undef u_message__
#undef s_message__
#undef ps_message__
#undef ph_message__


/* Main program alias */ int strek_main__ () { MAIN__ (); }
